将菜单项添加到WordPress管理菜单

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 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.

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的整个过程中单击后单击后再点击保存。 花一点时间将链接添加到现有菜单,这没有什么比让您更快移动的全新快捷方式了!

翻译自: https://davidwalsh.name/wordpress-admin-add-menu-item

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值