Last active
March 21, 2020 10:02
-
-
Save na0x2c6/25a2e1d713ac4b200883009936b1f652 to your computer and use it in GitHub Desktop.
WordPress: An example for adding noindex attribute to a page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_head', function() { | |
if(!(is_single() || is_page())){ | |
return; | |
} | |
$value = get_post_meta(get_the_ID(), 'is_noindex', true ); | |
if(!((int)$value)) { | |
return; | |
} | |
wp_no_robots(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment