Skip to content

How To Disable Search Engine Indexing On A Specific WordPress Post

Most of the time, you want Google to index your posts as soon as possible. But if you want to disable search engine indexing on a specific WordPress post, just use this trick. We will use custom fields to prevent Google and other search engines from indexing a specific page of your WordPress website.

Open your header.php file and paste the following code between the <head> and </head> tags:

<?php
    $noindex = get_post_meta($post->ID, 'noindex-post', true);

    if ($noindex) {
        echo '<meta name="robots" content="noindex,nofollow" />';
    }
?>

Now whenever you want to disable search engine indexing on a specific post, just add a custom field: noindex-post with any value in it to your post, and it will tell search engines to not index that page.

Leave a Reply

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