Skip to content

Instantly share code, notes, and snippets.

@na0x2c6
Last active March 21, 2020 10:02
Show Gist options
  • Save na0x2c6/25a2e1d713ac4b200883009936b1f652 to your computer and use it in GitHub Desktop.
Save na0x2c6/25a2e1d713ac4b200883009936b1f652 to your computer and use it in GitHub Desktop.
WordPress: An example for adding noindex attribute to a page
<?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