Advertisement
ten80snowboarder

WordPress Admin Default to PUBLISH posts in listing panel

Jun 2nd, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. add_action( 'admin_menu', 'ten80_default_published_posts' );
  2. function ten80_default_published_posts(){
  3.     global $submenu;
  4.  
  5. //  POSTS
  6.     foreach( $submenu['edit.php'] as $key => $value ){
  7.         if( in_array( 'edit.php', $value ) ){
  8.             $submenu['edit.php'][ $key ][2] = 'edit.php?post_status=publish&post_type=post';
  9.         }
  10.     }
  11.  
  12. //  OTHER POST TYPES
  13.     $cpt = array( 'page', 'portfolio' );    //  <--- remove or adapt the portfolio post type
  14.     foreach( $cpt as $pt ){
  15.         foreach( $submenu[ 'edit.php?post_type=' . $pt ] as $key => $value ){
  16.             if( in_array( 'edit.php?post_type=' . $pt, $value ) ){
  17.                 $submenu[ 'edit.php?post_type='.$pt ][ $key ][2] = 'edit.php?post_status=publish&post_type=' . $pt;
  18.             }
  19.         }  
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement