How to NOINDEX in WordPress

WordPress Optimized for Search Ranking

It is smart to begin with a caution before you learn how to NO-Index certain parts of your WordPress built website. Because getting these noindex directives for user-agents (search engines) like Googlebot wrong, can have unexpected results for websites built on WordPress.

The easiest way to noindex parts of a WordPress site is to use Meta Tags which you can place within the header.php head section (simply locate <head>portion of HTML</head>)

How to noindex WordPress Page

<?php if (is_page('nameOrIDofyourWordPressPage') : ?> <meta name="Googlebot" content="noindex"> <meta name="robots" content="noindex"> <?php endif; ?> Both WordPress page ID and Post ID can be found through the browser address bar as shown in this image: Shows WordPress Post ID in Browser Address Bar

How to noindex a Single Blog Post in WordPress

<?php if (is_single('nameOrIDofSingleBlogPost') : ?> <meta name="Googlebot" content="noindex"> <meta name="robots" content="noindex"> <?php endif; ?>

How to NoIndex WordPress Tags

<?php if (is_tag() : ?> <meta name="Googlebot" content="noindex"> <meta name="robots" content="noindex"> <?php endif; ?>

How to NoIndex a Single Category

Let’s imagine that you want to keep category with an ID 7 out of Google index, simply locate the Category ID (WordPress Dashboard > Posts Categories > Edit (and look for tag_ID=?)) as that’s your category ID. Then, you would use something like this: <?php if (is_category('7') : ?> <meta name="Googlebot" content="noindex"> <meta name="robots" content="noindex"> <?php endif; ?>

How to noindex Attachments in WordPress

All the file attachments you insert within your posts get their own URL’s as well. And if you want to noindex them, then use: <?php if (is_attachment() : ?> <meta name="Googlebot" content="noindex"> <meta name="robots" content="noindex"> <?php endif; ?>

How to noindex Search Results

<?php if (is_search() : ?> <meta name="Googlebot" content="noindex"> <meta name="robots" content="noindex"> <?php endif; ?>

Or You Can Use Below Codes to noindex Search Results

<?php if (is_search()) : ?> <meta name="description" content="<?php echo esc_html( get_search_query( false ) ); ?> is search query conducted on <?php bloginfo('url'); ?> website."> <meta name="keywords" content="<?php echo esc_html( get_search_query( false ) ); ?>, search results page"> <meta itemprop="description" content="<?php echo esc_html( get_search_query( false ) ); ?> is search query conducted on <?php bloginfo('url'); ?> website."> <meta itemprop="keywords" content="<?php echo esc_html( get_search_query( false ) ); ?>, search results page"> <meta name="Googlebot" content="noindex"> <meta name="Googlebot" content="follow"> <meta name="robots" content="noindex"> <meta name="robots" content="follow"> <!--searchqueries--> <?php endif; ?> As I’ve said at the beginning of this blog post, you have to be very careful about using noindex directives because what you are telling search engines is that they should not place that part of your WordPress in their index. And thus, no rankings for those parts of your website.

Do NOT Use robots.txt Directives for noindex

Most WP site owners believe that if they just use robots.txt file to deny access to certain parts of their website, then, those parts of the website will not be in Google search results.

However, that is not going to work for WordPress built sites because of the way WordPress is structured. Meaning, even if you use robots.txt file directives you still need to use meta tags specifically telling search engine to NO-INDEX parts of your website.

When Should You Use These

There is no set answer for this because each website is different. Perhaps the logic should be “do you have any unique content?” on the part of your website that you want to use noindex tags. Because you rank in Google for keywords that are within the uniqueness of your URL’s

As far as your pages, posts, products are using rel canonical URL then you can be more confident in your usage of noindex.

Furthermore: keep in mind that even if you get things wrong, then its just a matter of removing those tags and let Google re-crawl and re-index your website. If you want to speed this process up, then, share those URL’s you noindexed in the first place and things should be back to normal.

The New Google Search Console Indexation Coverage Reports and Errors

Search Console now shows more details about indexation issues, which are often confusing to investigate and fix for most site owners. However, when you follow this link Search Console Page Indexing Issues you’ll find solutions and explanations for remedying the typical URL indexation issues. Which are important to fix, or else, if Google can’t index a URL on a website, then it can not show it in its search results.

By RankYa

RankYa is a digital services provider dedicated to growing your sales and business website's results. Highly experienced technical problem solver, Google products expert with proven 'Social Media Marketing' skills, RankYa (100% Australian Owned and Operated) is dedicated to helping small businesses to grow.

We're looking forward to contributing towards your online success. Contact Us.


  1. Nice weblog here! Also your site loads very fast compared to mine. What host are you using? I wish my site loaded up as fast as yours lol

  2. i dont know how to edit this codes so i just added this code to my header.php files and i got this error back

    syntax error, unexpected ‘:’
    i tried changing : to ; then it came up with unexpected endif error i dont really know what to do and i would be grateful if you help look into the codes again

    1. Hello Olusegun, seems like a simple error for controlling indexing of web pages in WordPress. Simply email me the code and I’ll fix it for you.

  3. Hi RankYa.

    Thanks for the excellent information and better (if this is possible) explanation you have given.
    You have clarified many doubts regarding the operation of not indexing a url.

    Also it is great that you warn us about the care that must be taken when using this type of resources.

    I’m starting in the world of wordpress, but what I have clear from the beginning is that even when some of these things can be done with plugins, the less we use them is better.

    I have a question and I’m not asking you for a custom code, but a brief guide on whether it can be done.

    I have a page, in an affiliate site, which contains quality information to attract traffic, in addition to links to various amazon products placed with a plugin (to be able to automate prices, etc.)

    These products should be noindex to avoid duplicate content. One way to do that is to set the entire page as noindex, but I lose the value of the content that I wrote. The specific question is, on a page like that, can I set only the products section in noindex? (I know I could put all the information into a page and set it as index and link it to another with only the products and set the latter as noindex, but I would like to avoid that additional click.

    I have looked for specific documentation of the creator of the plugin (content egg specifically) but I have not achieved anything. I’m going to ask the creator of the plugin this same question, but how did I come across your information and I got the idea of asking you.

    Please excuse my lousy English, but I hope to have explained myself well.

    Once again, thank you very much for everything.

    1. Hello Juan, first, I wouldn’t send noindex directives for this scenario at all (because you’ve got additional content that you created) so thus Google will take that in to account and WILL NOT punish your site with duplicate content but rather rank your original content. But if you want to control indexation for particular part of your website (then, you do that NOT using a PLUGIN but rather place conditional PHP codes in to the header.php < head > section like this:

      < ?php if ( is_page('PageNameORid') ) : ?>

      < ?php endif; ?>

      I think this is what you are asking, because you do not need to control indexation for such case for URL’s on your own site, instead use nofollow, basically telling Google “hey Google index what you think is within your guidelines (which is your original content you placed on that URL on your affiliate site) but from THAT PARTICULAR URL do NOT follow the links from THAT PARTICULAR URL”

      This way, you are basically guiding Google as best that you can (now Google may index those other URL’s by following different links on your site OR from other external sites) which can’t be controlled anyway. Is this what you are asking?

  4. Dear sir,
    i see your most videos and posts about noindex. i got 188 page no index in new webmaster tool.
    but did not see any noindex tag in my pages.
    my website is wordpress and i am using for woocomerce purpose.
    some screen shot attached. i awaiting your kind and best reply

    1. That’s quite strange indeed because after checking sample URL, I can’t see how Google would be served noindex for some URL’s, I would use fetch as Google feature to double check, if all is good validate fix to see what happens (it will either be validated or it won’t) this will tell you IF Google had an issue with index coverage in particular moment in time. I would really like to know the results. Also, setup Yoast better for your site (particularly the xml sitemaps) RankYa blog has the information for using Yoast with best settings

  5. Knowing how to index is imperative to a successful Website and this article is helped me quite a bit.

    There’s so much more than just optimizing content. Website optimization is definitely critical to any business goal or objective!

    Thank you

Questions? Leave a Comment!

Your email address will not be published. Required fields are marked *