Hide/Exclude a Page in Edit Pages Section in WordPress Dashboard
(Last Updated On: July 10, 2014)
If you’re searching for a way where you can tailor the admin dashboard pages (Edit Pages Section). Let’s take an example:
You have a blog page on a WordPress site, but that blog page is fed from posts in the post section. And you want to remove that Blog page from the pages section. Following is a tip to exclude or hide a page from edit pages section. Let’s say page ID is “15“.
add_action( 'pre_get_posts' ,'exclude_this_page' ); function exclude_this_page( $query ) { if( !is_admin() ) return $query; global $pagenow; // WordPress 2.9 if( 'edit-pages.php' == $pagenow ) $query->set( 'post__not_in', array(15) ); // WordPress 3.0 /* if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) ) $query->set( 'post__not_in', array(15) ); */ return $query; }