• Resolved ichanx

    (@ichanx)


    Hi,
    I need to noindex some of my my posts from googlebot only (still indexed in Bing, yandex, etc).
    I have grouped those posts into one category, and follow the instruction here: https://rankmath.com/kb/how-to-noindex-all-posts-in-a-category/

    Unfortunately, this means that those posts will be set to noindex for every robots. Is there any way that I can do to set a robots meta tag to noindex only from googlebot?

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @ichanx,

    Thank you for contacting the support.

    You can add the following filter to prevent GoogleBot from crawling and indexing your site:

    add_action( 'wp_head', function() {
    	   ?>
    	   <meta name="googlebot" content="noindex, nofollow">
    	   <?php
       } );

    You can follow this guide to add the code:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps.

    Thread Starter ichanx

    (@ichanx)

    That filter that you wrote will block googlebot from the whole site. I only want to implement it to some of my post page.

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @ichanx,

    You can add a condition in the filter that applies the tag only to the required posts.

    Here’s an example code:

    add_action( 'wp_head', function() {
    	$post_ids = [1044, 1033];    // Add required post IDs 	
    	if(in_array(get_the_ID(), $post_ids)):
          ?> 
          <meta name="googlebot" content="noindex, nofollow"> 	   
          <?php 	
        endif; 
    } );

    You can replace the IDs in $post_ids variable with the IDs of posts where the tag is to be applied.

    Here’s how you can get the post ID:
    https://i.rankmath.com/ugC4iA

    Hope this helps. Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How To Noindex Only From Googlebot, and Still Normal To Other Robots?’ is closed to new replies.