Skip to content

Instantly share code, notes, and snippets.

@tdtgit
Last active May 15, 2017 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdtgit/9f6fe1878bddf2a1f1ce6c654be13be2 to your computer and use it in GitHub Desktop.
Save tdtgit/9f6fe1878bddf2a1f1ce6c654be13be2 to your computer and use it in GitHub Desktop.
<?php
// Allow logged-in user see private posts in
add_action('pre_get_posts','filter_search');
function filter_Search($query){
if( is_admin() || ! $query->is_main_query() ) return;
if( current_user_can('edit_private_posts') ) {
$query->set('post_status',array('private','publish'));
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment