remove meta robots tag

#787665
  • Resolved Mediafeed
    Rank Math free

    I have written a plugin to put in our meta name=”robots” tag, there’s some strange logic we need. So I am trying to suppress the robots tag that rankmath is automatically inserting. The closest I’ve come is adding this to rank-math.php in my theme dir:

    add_filter( ‘rank_math/frontend/robots’, function( $robots ) {
    unset($robots[‘index’]);
    unset($robots[‘follow’]);
    return $robots;
    });

    however, that leaves in the others like max-snippet max-video-preview, etc… I’ve tried to remove them using the same filter as well as the rank_math/snippet/rich_snippet_article_entity filter, but that had no effect. Is there a way to just completely suppress the meta robots tag?

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

    I understand that you are trying to suppress the meta robots tag that Rank Math automatically inserts and have tried using a filter in your rank-math.php file but are still facing issues with other directives like max-snippet and max-video-preview remaining.

    To completely suppress the meta robots tag added by Rank Math, you can modify your existing filter to remove all directives. Here is the updated code snippet that should help you achieve this:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
        // Remove all directives
        $robots = array();
        return $robots;
    });

    By using this updated filter, you will effectively suppress all meta robots directives added by Rank Math. Please replace your current filter with this code snippet in your rank-math.php file and save the changes.

    If you encounter any further issues or need additional assistance, please feel free to ask. Thank you for reaching out with your concern.

    Sources:
    How to Make Your Theme Rank Math Compatible » Rank Math
    How to Disable All Rank Math Generated SEO Tags » Rank Math
    How to Use the Noydir Robots Meta Tag » Rank Math

    this does not remove the meta robots tag, the ones mentioned like max-snippet are still present.

    Hello,

    Thank you for contacting us and sorry for any inconvenience that this issue might have caused.

    To ensure those are not added head over to Rank Math > Titles & Meta > Global Meta > Advanced Robots Meta and uncheck the Snippet, Video Preview, and Image Preview checkboxes, then click the Save Changes button below.
    https://imgur.com/8OlYySD

    2. Once done, apply this filter on your site to remove the default index and follow robots meta tags:

    add_filter('rank_math/frontend/robots', function( $robots ) {
    	unset($robots['index']);
        unset($robots['follow']);
    return $robots;
    });

    If you’re not sure how to add this code, you can follow this guide:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how this goes. Also, let us know if you have further questions or concerns.

    Thank you.

    it seems that for existing content these things got checked by default – there’s no way to just have them be removed for all?

    Hello,

    Please replace the former code with the following to remove the entire Rank Math robots meta line:

    add_filter( 'rank_math/frontend/advanced_robots', function( $robots ) {
    	unset($robots['max-snippet']);
        unset($robots['max-video-preview']);
    	 unset($robots['max-image-preview']);
    return $robots;
    });
    	
    add_filter('rank_math/frontend/robots', function( $robots ) {
    	unset($robots['index']);
        unset($robots['follow']);
    	return $robots;
    });

    Let us know how that goes.

    We look forward to hearing back from you.

    Thank you! My robots just were not advanced enough. Appreciate this.

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘remove meta robots tag’ is closed to new replies.