Drafts Link Under Every Post Type Menu
Adds a "Drafts" submenu under Posts, Pages and each custom post type for one-click access to unfinished content.
Opens WPIDE on
Code
add_action( 'admin_menu', function () {
foreach ( get_post_types( array( 'show_ui' => true, 'show_in_menu' => true ), 'objects' ) as $type ) {
if ( 'attachment' === $type->name || true !== $type->show_in_menu ) {
continue;
}
$parent = 'post' === $type->name ? 'edit.php' : 'edit.php?post_type=' . $type->name;
add_submenu_page(
$parent,
'Drafts',
'Drafts',
$type->cap->edit_posts,
'edit.php?post_type=' . $type->name . '&post_status=draft'
);
}
}, 20 );
Notes
Post types that sit inside another plugin menu are skipped.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.