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?
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 foreach
s.
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;
}
}
}
}