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.

1 thought on “How To Disable Search Engine Indexing On A Specific WordPress Post”

  1. Hi, Hardeep.

    I’m trying to use this code for noindexing some posts on my website, but it doesn’t seem to work.
    Is it still usable?

    My config:
    – WordPress: 6.4.3.
    – GeneratePress Theme: 3.4.0.
    – WPCode Lite: 2.1.10.

    Thank you very much.

Leave a Reply

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