
Some days ago, I shown you how to disable search engine indexing on a single post. One of WpRecipes reader, Kevin Paquet, asked me how to do the same thing on a specific category. Here is the answer to Kevin question.

Some days ago, I shown you how to disable search engine indexing on a single post. One of WpRecipes reader, Kevin Paquet, asked me how to do the same thing on a specific category. Here is the answer to Kevin question.
To achieve, first get the ID of the category you'd like to be not indexed by search engines. In this exemple, I assume your category id is 8.
Open your header.php file and paste the following code between the <head> and </head> tags:
<?php if ( is_category('8') || in_category('8') ) {
echo '<meta name="robots" content="noindex">';
}
That's all. With the above code, we made sure that no post from category with the ID 8 as well as category pages will be indexed by search engines crawlers.
6 Responses
Thanks
Wow, thanks for answering my question, but I guess I’ll stick t what I did since it has required me much effort already. I have setup a different single.php’s for those posts of categories that I don’t want to be indexed and created a special header file which contains the nofollow,noindex statement. Reverting everything would make my effort useless :p
Trackbacks: