Skip to content

Instantly share code, notes, and snippets.

@steppohub
Last active August 29, 2015 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steppohub/e8fc702b140f2f36c738 to your computer and use it in GitHub Desktop.
Save steppohub/e8fc702b140f2f36c738 to your computer and use it in GitHub Desktop.
Hide pages from non administrators
// hide specific pages from the All pages list, choose ids manually!
add_action( 'pre_get_posts' ,'exclude_this_page' );
function exclude_this_page( $query ) {
if( !is_admin() )
return $query;
global $pagenow;
if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) )
$query->set( 'post__not_in', array('4', '5','6','7', '8') );
return $query;
}
// note if you really want the if not conditional to work properly you'd put if (! current_user_can( 'manage_options' ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment