Skip to content

Instantly share code, notes, and snippets.

@ptasker
Created November 29, 2013 19:09
Show Gist options
  • Select an option

  • Save ptasker/7710508 to your computer and use it in GitHub Desktop.

Select an option

Save ptasker/7710508 to your computer and use it in GitHub Desktop.
<?php
function pre_exclude_pages_from_admin($query) {
if ( ! is_admin() )
return $query;
global $pagenow, $post_type;
if ( !current_user_can( 'administrator' ) && is_admin() && $pagenow == 'edit.php' && $post_type == 'page' ) {
$query->query_vars['post__not_in'] = array( '10', '167', '205' ); // Enter your page IDs here
}
}
add_filter( 'parse_query', 'pre_exclude_pages_from_admin' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment