Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

Thanks,

osu

share|improve this question

1 Answer

up vote 3 down vote accepted

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;
 }
share|improve this answer
If you globalise $post_type you'd not need to reference $_GET to check the post type(it does get reliably set for admin pages - unlike $typenow). – t31os Mar 30 '11 at 21:42
@t31os: Thanks for the tip, i updated the code. – Bainternet Mar 30 '11 at 21:46
thanks for this, looks like a great solution! – Osu Mar 31 '11 at 6:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.