Advertisement
ten80snowboarder

WordPress show PUBLISH status posts by default

Aug 16th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. //  SHOW "publish" POSTS ONLY BY DEFAULT -----------------------------------------------------
  2. add_action( 'admin_menu', 'my_default_published' );
  3. function my_default_published(){
  4.     global $submenu;
  5.  
  6.     // POSTS
  7.     foreach( $submenu['edit.php'] as $key => $value ){
  8.         if( in_array( 'edit.php', $value ) ){
  9.             $submenu['edit.php'][ $key ][2] = 'edit.php?post_status=publish&post_type=post';
  10.         }
  11.     }
  12.  
  13.     // OTHER POST TYPES
  14.     $cpt = array( 'my_cpt_1', 'my_cpt_2' );     // <--- remove or adapt the post types
  15.     foreach( $cpt as $pt ){
  16.         foreach( $submenu[ 'edit.php?post_type=' . $pt ] as $key => $value ){
  17.             if( in_array( 'edit.php?post_type=' . $pt, $value ) ){
  18.                 $submenu[ 'edit.php?post_type='.$pt ][ $key ][2] = 'edit.php?post_status=publish&post_type=' . $pt;
  19.             }
  20.         }  
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement