› Noindex posts within specific categories in WordPress

Noindex posts within specific categories in WordPress

Email this to someoneShare on Facebook0Share on Google+0Share on LinkedIn0Share on Tumblr0Share on StumbleUpon0Tweet about this on TwitterShare on Reddit0Pin on Pinterest0

I ran into a situation that required bulk de-indexing (applying the noindex tag) of hundreds of posts within a specific category. One may run into a similar issue with syndicated content that does not need to be indexed in Google, or with content that’s primarily for users in my case, but is served from a landing page.

I looked for a plugin to handle the problem but couldn’t find one, so I came up with my own little solution. It may be a plugin project for the future.

“No-indexing” posts within specific categories is also handy because you can use the bulk/quick edit screen to easily add post taxonomy. You can also do this with pages using a plugin like this.

Here’s how to no-index posts from a specific category:

Add the following code between the <head> tags in your header.php theme file:

<?php // no index specific categories
if (in_category('category-slug')) { ?>
<meta name="robots" content="noindex">
<?php } ?>

If you’d rather use tags instead, try this:

<?php // no index specific tags
  if (has_tag('tag-slug')) { ?>
    <meta name="robots" content="noindex">
<?php } ?>

Remember to swap out ‘category-slug’ or ‘tag-slug’ with your own taxonomy’s slug. Make sure you leave the quotation marks intact.

Subscribe for weekly tutorials

  • WorldHomeopathic Directory

    Thanks for great article which helped me. to mass no index wordpress posts.