How to block Google from indexing Thank You Pages

Hi there

I’ve got several freebies/lead magnets on my website that visitors will need to put their name and email address in to access. However, once the visitor has entered their name and email, they are taken to a Thank You page where they can download their lead magnet.

I don’t want this Thank You page to appear in Google or other search engine results. Is there a way that I can add some code to these Thank You pages to prevent Google and other search engines from indexing them?

I’ve found the following code, which I believe will do the job, but I don’t know where to put it in X-Theme:

Any help will be much appreciated. Thank you.

Hi There,

Thanks for writing in! The following resource may help you on that (


Thanks for getting back to me with that resource.

The link you sent is for temporary blocking a resource; I’d prefer to have a permanent block on these pages. With this in mind, would this work:

If so, please would you be able to let me know where I can add code into the header on X-Theme?

Thank you

Hi There,

You can add this to your child theme’s functions.php file.

prevent search engine web crawlers
function prevent_crawlers () { 
 if ( is_page (46) ) : ?>
<?php endif; 
add_action('wp_head','prevent_crawlers', 1);

This will output that <meta> line on the <head> part of a specific page.

Replace the 46 on the code with your actual “Thank You page” ID.

How To Locate Post/Page IDs

How To Setup Child Themes

Hope it helps,

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.