PHP snippet code in header (for noindexing) doesn’t work
-
Hi. I’m trying to allow noindexing posts and pages (for Google) through a custom field using this code:
$noindex = get_post_meta($post->ID, 'noindex-page', true); if ($noindex) { echo '<meta name="googlebot" content="noindex,follow" />'; }The code needs to be in the header, so I’m setting the location in WPCode to “Site Wide header” and activated it.
I’m putting a value in the “noindex-page” custom field for the desired post, but nothing occurs when checking the source code of the post.
Could you please advise me on how to solve this issue?
Thank you very much.
PS: I’m using:
– WordPress: 6.4.3.
– GeneratePress Theme: 3.4.0.
– WPCode Lite: 2.1.10.
The topic ‘PHP snippet code in header (for noindexing) doesn’t work’ is closed to new replies.