How to noindex, follow a specific category wordpress?

There are several robots.txt generators online. Here is one of my favorites. After you’ve generated your file, I highly recommend testing it with Google’s Webmaster Tools tester.

I’ve done this for dozens of sites, and never have a problem.

Just remember the following:

  • Most WordPress sites treat categories as if they’re folders/directories. So, to make a rule for the breads category, you may need /topics/breads/, or /category/breads/, or even /cat/breads/ … depending on your site’s Settings.
  • If you continue to have trouble, you can Deny All by default. Then you would have to expressly permit each category/folder/topic/etc. that you want to have indexed.

EDIT
Google provides the following recommendation, which have also worked for me:

//To prevent only most web crawlers from indexing a page:
<meta name="robots" content="noindex">

– or –

//To prevent only Google web crawlers from indexing a page:
<meta name="googlebot" content="noindex">

EDIT
I recommend you use a category template. This WPBeginner Article explains how to create them, in case you have not done this before. Basically, you’ll usually start by copying your “index.php” or “page.php” to a new “category.php” file. Then, make a couple of simple edits.

Depending on how many categories should be ignored, my typical suggestion might be to create a single category.php template, then use an “If” statement like the following in the template:

// noIndex = list of categories that should be ignored by bots
$noIndex = array('cats','rats','bats',...);
// current_category = category of the page currently being prepared
$current_category = get_the_category();
// If the current_category is in the list of those to be ignored...
if ( in_array($current_category, $noIndex) ){
    // add a filter to insert the meta tag
    function ignore_category_indexing() {
        echo '<meta name="robots" content="noindex" />';
    }
    add_action( 'wp_head', 'ignore_category_indexing' );        
}

Good luck!

P.S. If this works for you, I could use a Vote Up..