How to noindex in WordPress - The Right Way

How to noindex in WordPress

 In WordPress

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 () like wrong, will have drastic results for your website built on WordPress. Now that you are warned.

The easiest way to 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

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 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 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 . Meaning, even if you use robots.txt file directives you still need to use 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 for keywords that are within the uniqueness of your URL’s

As far as your pages, posts, products are  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

the newest Search Console now shows more details about indexation issues, which are often confusingn to investigate and fix. However, when you follow this link Search Console Index Coverage 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 your website, then it can not rank it in its search results.

Recommended Posts
Showing 11 comments
  • Peter
    Reply

    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

    • RankYa
      Reply

      Absolutely correct, and noindex options is WordPress are actually easy and great for better optimization of URL’s

  • Saqib Mughal
    Reply

    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

    • RankYa
      Reply

      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

  • Juan Lavieri
    Reply

    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.

    • RankYa
      Reply

      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?

  • Halil
    Reply

    php?id=1317

    such links are added to the directory. How can I help prevent this?

    • RankYa
      Reply

      URL parameters are a great way to tell Google about these types of links.

  • olusegun
    Reply

    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

Leave a Comment

0

Start typing and press Enter to search

How to Create a Membership Site with WordPressWordPress CMS Optimized