How to disable <meta name="robots" from RankMath plugin?

#389570
  • Resolved Afrodrops
    Rank Math free

    Hi support!

    For context…
    We have custom rules on our WP site that defines whether a page should be rel=”nofollow,noindex” or it should be left as default and is therefore crawlable by search engines.

    The problem that the RankMath plugin is giving us is on pages where we’ve specified via our custom rules that the page is rel=”nofollow,noindex”, RankMath is sending rel=”index,follow” causing conflicting signals.

    What we’d love help with!

    We therefore need to disable RankMath from outputting <meta name=”robots” rel=”follow,index” lines on all of our web pages.

    Please could you let me know the code I’d need to add to functions.pho to disable this or how I can achieve this?

    Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    Thank you for contacting Rank Math support, and sorry for any inconvenience that might have been caused due to that.

    To force Rank Math to output nofollow and noindex to your robots meta, please refer to this filter code here:

    /**
     * Rank Math: filter the robots meta data.
     *
     * @param array $robots The meta robots directives.
     */
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    	unset( $robots['index'] );
    	unset( $robots['follow'] );
    	return $robots;
    });

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Jeremy,

    You’re a hero! Thank you.

    I just want to double check something…

    This won’t force rel=”nofollow,noindex” onto every page, correct?

    This will just prevent rel=follow,index” from showing unless I specify otherwise?

    Thanks!

    Hi Jeremy,

    Thanks so much for your help – I’ve tried the code and it works as expected.

    One small issue, though…

    The <head> still has two <meta name “robots”..> tags which is still causing issues (although the one output by RankMath does not have ‘index, follow’ anymore so it’s better.

    The RankMath meta robots tag is now ‘<meta name=”robots” content=”max-snippet:-1, max-video-preview:-1, max-image-preview:large”/>’

    The best thing to do is prevent RankMath from outputting a robots tag at all to avoid conflicts

    Would you happen to know the correct code to do this?

    Hello,

    This won’t force rel=”nofollow,noindex” onto every page, correct?

    You would need to create a logic to run the code for only specific pages.

    The best thing to do is prevent RankMath from outputting a robots tag at all to avoid conflicts

    The robots meta tags are an integral part of our plugin and can’t be removed completely from the HTML with any filter.

    This tag is added as part of our action rank_math/head that is used to generate all the meta tags inside the header.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this ticket.