Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

As it is, WordPress displays by default all the pages/posts in the pages/posts list in the admin area, no matter what their publishing status is.

I have a lot of drafts, but usually I'm much more interested in editing the published pages/posts, therefore getting only to display them requires another click and full reload.

Is there a way to set WordPress to initially display only published posts/pages, allowing you to click on "All" or "Draft" if you later want to?

share|improve this question
    
Anyone? I was told several times recently that if you want to get quick answers re WordPress - StackExchange is the place to go... Any answer would be appreciated - thanks. –  yudayuda Mar 21 '13 at 11:30
add comment

1 Answer

I'm not sure if there's another way, but manipulating the global variable $submenu can make this work.

The following is just a manual hack (I'm not aware of any hook) and may fail on non-standard submenus set ups. The regular Post post type has a unique address and the rest of types has another one, hence two foreachs.

add_action( 'admin_menu', 'default_published_wpse_91299' );

function default_published_wpse_91299() 
{
    global $submenu;

    // POSTS
    foreach( $submenu['edit.php'] as $key => $value )
    {
        if( in_array( 'edit.php', $value ) )
        {
            $submenu['edit.php'][ $key ][2] = 'edit.php?post_status=publish&post_type=post';
        }
    }

    // OTHER POST TYPES
    $cpt = array( 'page', 'portfolio' ); // <--- remove or adapt the portfolio post type
    foreach( $cpt as $pt )
    {
        foreach( $submenu[ 'edit.php?post_type=' . $pt ] as $key => $value )
        {
            if( in_array( 'edit.php?post_type=' . $pt, $value ) )
            {
                $submenu[ 'edit.php?post_type='.$pt ][ $key ][2] = 'edit.php?post_status=publish&post_type=' . $pt;
            }
        }   
    }
}
share|improve this answer
add comment

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.