[resolved] A way to hide a page in admin panel ONLY (7 posts)

  1. matius
    Posted 6 years ago #

    sup everybody, is there a way I can tailor the control panel pages only for my client?

    For example, I have a blog page on the site... but the blog page is fed from posts... in the post section. I want to remove the "Blog" page just from the Pages section so not to confuse my client...


  2. Mark / t31os

    Posted 6 years ago #

    Exclude page with the ID 23 from the edit pages list.

    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(23) );
    	// WordPress 3.0
    	if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) )
    		$query->set( 'post__not_in', array(23) );
    	return $query;

    23 is of course an example ID, adjust as necessary..

    NOTE: This doesn't stop the post being editable if you know the ID, it's just hidden from the page listing (i assumed that's what you want though).

  3. matius
    Posted 6 years ago #

    Ah, cool. Thanks much!

  4. Mark / t31os

    Posted 6 years ago #

    You're welcome.. :)

  5. iftomkins
    Posted 5 years ago #

    Is there any way to do this for all users EXCEPT administrator? Thanks!

  6. kirkward
    Posted 5 years ago #

    Is this added in functions.php?

  7. I'm assuming that this is added in the functions.php file, right?

    And will I have to re-add it everytime I update or change themes?

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.