Hide a page in the admin end without a plugin?

I’m creating a series of pages with iFrames embedded in them, but it seems the only way to do this within WordPress (i.e. using the templating system) is to create pages in the admin end and then create individual templates for each of those pages.

Is it possible to hide those pages from the admin without a plugin? I see no need for the client to see those pages when they can’t edit anything in them.

Read More

Thanks,

osu

Related posts

Leave a Reply

1 comment

  1. you can use parse_query filter hook to exclude your pages using post__not_in attribute

    add_filter( 'parse_query', 'exclude_pages_from_admin' );
    function exclude_pages_from_admin($query) {
        global $pagenow,$post_type;
        if (is_admin() && $pagenow=='edit.php' && $post_type =='page') {
            $query->query_vars['post__not_in'] = array('21','22','23');
        }
    }
    

    this will exclude pages with the ids of 21,22,23

    and to make sure this pages will not be included on the front end using wp_list_pages
    you can use wp_list_pages_excludes filter hook:

     add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages');
     function exclude_from_wp_list_pages($exclude_array){
        $exclude_array = $exclude_array + array('21','22','23');
        return $exclude_array;
     }