Want to ask search engines not index or follow one of your pages or posts? It’s really pretty simple. Here’s how I do it.
- Add code to your header to insert the
meta robotstag with noindex,nofollow - Add the custom field to any post or page
Insert Code For Your Header
Edit your templates header.php file and locate the meta viewport tag.
<meta name="viewport" content="width=device-width">After the meta viewport tag, insert this script to generate the meta robots noindex,nofollow tag:
<?
// meta robots noindex nofollow tag script:
$noindex = get_post_meta(get_the_ID(), 'noindex', true);
if ($noindex) {
echo '<meta name="robots" content="noindex,nofollow" />';
}
?>Add custom field to the page
After you update the header.php file, you can use the noindex custom field on any page or post. I use true as the value, but it really does not mater. If the noindex field is present, the meta robots tag will get inserted.
