Skip to content

Instantly share code, notes, and snippets.

@josepedrodiaz
Created February 21, 2022 19:39
Show Gist options
  • Save josepedrodiaz/28d309bfb15286841aded7f32413d355 to your computer and use it in GitHub Desktop.
Save josepedrodiaz/28d309bfb15286841aded7f32413d355 to your computer and use it in GitHub Desktop.
No index password protected posts
<?php
/**
* Noindex protected posts
*/
add_filter( 'wp', function()
{
global $post;
if(!empty($post->post_password)){
add_filter( 'wp_robots', 'wp_robots_no_robots' );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment