This is a great little snippet that will exclude pages based on the the ID from the admin pages list. Just add this snippet to the functions.php of your wordpress theme and update the array with the page ID’s you wish to hide. Please note this does not stop a post from being editable this snippet only hides the page from view.
1 2 3 4 5 6 7 8 9 |
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(23,28,30) ); // page id return $query; } |