Created
August 31, 2016 14:33
-
-
Save ingozoell/d086eeacf3b724e26c787f0e9d76e906 to your computer and use it in GitHub Desktop.
How to display by default only published posts/pages/cpt in the admin area?
http://wordpress.stackexchange.com/questions/91299/how-to-display-by-default-only-published-posts-pages-in-the-admin-area
http://wpcodesnippet.com/change-pages-link-display-published-pages/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', 'product' ); | |
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; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment