Change the Default Pages Menu View in wp-admin

I can’t seem to figure out how to change the default view for “Pages” in the admin menu.

The initial view is the “Pages” view (/wp-admin/edit.php?post_type=page)

Read More

How could it change this to something else?
Like “Add New Page”? (/wp-admin/post-new.php?post_type=page)

I’ve tried several different options including rebuilding the menu with a custom menu, but it seems like WordPress automatically keeps redirecting the “Pages” view (/wp-admin/edit.php?post_type=page).

Related posts

Leave a Reply

3 comments

  1. [Update]
    Answer rewritten, based on this other Q&A.


    To achieve this:

    default pages menu view

    Use this code:

    add_filter( 'custom_menu_order', 'wpse_48933_submenu_order' );
    
    function wpse_48933_submenu_order( $menu_ord ) 
    {
        global $submenu;
    
        // Enable the next line to inspect the $submenu values
        // echo '<pre>'.print_r($submenu,true).'</pre>';
    
        $arr = array();
        $arr[] = $submenu['edit.php?post_type=page'][10];
        $arr[] = $submenu['edit.php?post_type=page'][5];
        $submenu['edit.php?post_type=page'] = $arr;
    
        return $menu_ord;
    }
    
  2. In a custom plugin, use this PHP to remove the Pages page.

    add_action( 'admin_menu', 'my_custom_pages' );
    
    function my_custom_pages() {
        remove_menu_page('edit.php?post_type=page'); // Pages
                add_menu_page('Pages', 'Pages', 'author', 'pages', 'my_custom_menu_page' );
    }
    
    function my_custom_menu_page() {
        // The function to load your new page
    }
    

    This will need customizing, but it takes care of removing the original and replacing it with yours.

  3. A different way of doing this is to add your custom query variable into the loading of the page.

    add_action('pre_get_posts', 'my_custom_query_vars' );
    function my_custom_query_vars() {
        $screen = get_current_screen();
        if ( $screen->id == 'edit-page' ) {
            set_query_var( 'orderby', 'custom_page_order' );
        }
    }