Is there a way to remove or hide individual pages on the Edit Pages screen?

I want to create a handful of pages that I do not want the client to have access to through the edit pages admin screen.

I do want the pages to have all the normal functionality of pages in other parts of the control panel. For example, I want the pages to show on… Appearance > Menus …so the client can reorder or rename them in the navigation.

Read More

I found a question that almost had the perfect solution…

Create a page without adding a page in the Database

The answer was great – it forces the use of a template based on a key=>value pair in the URL, which means the “page” can exist without actually creating a page. The downside is that it doesn’t behave like a page in other places (ex: not a custom menu option as mentioned above) because its not actually a page.

The ideal solution for me would be to create a real page and filter it out when the Edit Pages screen is loaded, but I’m not sure how to do that.

I’m open to completely different approaches, but if a custom page template is any part of the solution then the solution also needs to remove the page template as an option from the drop-down when editing other pages, so that the client can’t replicate these pages.

Thanks in advance for the help.
~ Kirkland

Related posts

Leave a Reply

1 comment

  1. Indeed there is a way.

    function wpa53074_admin_exclude_page( $query ) {
        if( !is_admin() )
            return $query;
    
        global $pagenow;
        if( 'edit.php' == $pagenow && 'page' == get_query_var( 'post_type' ) )
            $query->set( 'post__not_in', array( 99 ) ); // <- page ID to hide
    
        return $query;
    }
    add_action( 'pre_get_posts', 'wpa53074_admin_exclude_page' );