Created
June 13, 2013 08:42
-
-
Save bonny/5772182 to your computer and use it in GitHub Desktop.
WordPress function that uses filter "wp_head" to add meta robots noindex for password protected pages
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 | |
// if current page is password protected then kindly tell google (aka search engines) to not index the current page | |
function ep_noindex_password_protected_pages() { | |
global $wp_the_query; | |
if ( $wp_the_query->is_singular && post_password_required( $wp_the_query->get_queried_object ) ) { | |
wp_no_robots(); | |
} | |
} | |
add_action("wp_head", "ep_noindex_password_protected_pages"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment