Last active
August 29, 2015 14:06
-
-
Save steppohub/e8fc702b140f2f36c738 to your computer and use it in GitHub Desktop.
Hide pages from non administrators
This file contains 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
// 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