How To Stop Search Engines From Indexing Specific Pages

Add the Robots Meta Tag to Your Theme Header:

The first thing you need to do is add the following code to the head section of your theme’s header.php template.


<?php $noindex = get_post_meta($post->ID, 'noindex-post', true);
 
    if ($noindex) {
        echo '<meta name="robots" content="noindex,nofollow" />';
    }
?>

You do not need to modify the code above and insert your post ID or post title. Instead of specifying the post or page to block in the code itself, you do it using a custom field. Click add a  custom field give name noindex-post and assign a value noindex-post to it.

Simply repeat the above step for any post type you want to block from search engines.

I believe this is one of the most user friendly techniques that a developer can configure for a client, as it so simple to block additional posts and pages. However, it does not give you a quick way of seeing which posts and pages are blocked from search engines, and which are not.

ABOUT AUTHOR

Nuno

I am a Freelance Web Developer and WordPress Expert based in London with a wealth of website development and support experience. I am great at problem solving and developing quick solutions.

LEAVE A COMMENT

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • LET'S TALK!

    Fill in the form below to make an enquiry or find my contact details on my contact page.

  • This form collects your name and email address so that I can respond to the enquiry(ies) that you submit via this website. Please check my privacy policy for the full story on how I use, protect and manage your submitted data.