In this article, we are going to discuss about How to add extra menu items to the WordPress admin menu. WordPress is a free and open source blogging tool and a content management system (CMS) based on PHP and MySQL. In WordPress, if we want to navigate to the Drafs menu, we need to click on the "All Posts" link and then only we can find the "Drafts" link. If you simply need this in "Posts" menu follow the below code.
Open the "functions.php" file of our current theme and add the following codes.
// Add menu item for draft posts
function add_drafts_admin_menu_item() {
// $page_title, $menu_title, $capability, $menu_slug, $callback_function
add_posts_page(__('Drafts'), __('Drafts'), 'read', 'edit.php?post_status=draft&post_type=post');
}
add_action('admin_menu', 'add_drafts_admin_menu_item');
The add_posts_page method is actually a shortcut for add_submenu_page, which allows you to add a submenu item for any existing menu item. And WordPress allows you to get pretty detailed with your own menus, as you can see here.
Open the "functions.php" file of our current theme and add the following codes.
// Add menu item for draft posts
function add_drafts_admin_menu_item() {
// $page_title, $menu_title, $capability, $menu_slug, $callback_function
add_posts_page(__('Drafts'), __('Drafts'), 'read', 'edit.php?post_status=draft&post_type=post');
}
add_action('admin_menu', 'add_drafts_admin_menu_item');
The add_posts_page method is actually a shortcut for add_submenu_page, which allows you to add a submenu item for any existing menu item. And WordPress allows you to get pretty detailed with your own menus, as you can see here.
0 comments:
Post a Comment