The existing menus in WordPress are solid but one annoyance is that I need to click "All Posts" and then the "Drafts" link to get to my drafts; I simply want to get there as quickly as possible via the Posts menu. I did some quick research on the topic and in two minutes I was able to add a "Drafts" submenu item to the "Posts" menu. Here's how I did it!
WordPress中的现有菜单是可靠的,但令人烦恼的是,我需要单击“所有帖子”,然后单击“草稿”链接以获取我的草稿; 我只是想通过“帖子”菜单尽快到达那里。 我对该主题进行了一些快速研究,并在两分钟内将“草稿”子菜单项添加到“帖子”菜单中。 这是我的方法!
Within the functions.php file of my current theme (this file gets loaded even for admin!), I added the following:
在当前主题的functions.php文件中(即使是管理员也要加载该文件!),我添加了以下内容:
// Add menu item for draft postsfunction 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.
add_posts_page
方法实际上是add_submenu_page
的快捷方式,它允许您为任何现有菜单项添加子菜单项。 WordPress使您可以使用自己的菜单获得相当详细的信息,如此处所示。
This added "Drafts" link will save me click after click after click throughout my time using WordPress. Take the few moments to add links to existing menus as you'd like -- there's nothing like a fresh shortcut to get you moving faster!
这个添加的“草稿”链接将使我在使用WordPress的整个过程中单击后单击后再点击保存。 花一点时间将链接添加到现有菜单,这没有什么比让您更快移动的全新快捷方式了!
翻译自: