Wordpress:更改管理子菜单顺序 [英] Wordpress: Change admin submenu order
问题描述
我已经创建并注册了一个管理页面作为帖子"管理菜单下的子菜单.但问题是它出现在 wp 子菜单的末尾(即在标签"之后),
I have created and registered an admin page as a sub-menu under 'Posts' admin menu. But the problem is its coming at the end of the wp-submenus(ie., after 'Tags'),
如何更改此自定义管理页面子菜单条目的顺序以显示在添加新"之后?
How to change the order of this custom admin page submenu entry to appear after 'Add new' ?
我正在使用此功能在edit.php(帖子菜单)下注册我的子菜单
I'm using this function to register my sub-menu under edit.php(Posts menu)
add_submenu_page(
'edit.php',
"my custom submenu",
"my custom submenu",
CAPABILITY,
'my_custom_submenu',
"scrollcore_newsroom_articles"
);
推荐答案
找到解决方案,只需要将此函数添加到你的functions.php
Found the solution, just need to add this function to your functions.php
/*Change menu-order*/
add_filter( 'custom_menu_order', 'so_18766477_submenu_order' );
function so_18766477_submenu_order( $menu_ord )
{
global $submenu;
// Enable the next line to see all menu orders
//echo '<pre>'.print_r($submenu,true).'</pre>';
$arr = array();
$arr[] = $submenu['edit.php'][5]; //my original order was 5,10,15,16,17,18
$arr[] = $submenu['edit.php'][10];
$arr[] = $submenu['edit.php'][18];
$arr[] = $submenu['edit.php'][17];
$arr[] = $submenu['edit.php'][15];
$arr[] = $submenu['edit.php'][16];
$submenu['edit.php'] = $arr;
return $menu_ord;
}
这里通过选择 edit.php,我的目标是帖子"菜单.您可以选择任何您希望其子菜单重新排序的文件,例如 plugins.php、themes.php、tools.php 等
Here by choosing edit.php, I'm targeting 'Posts' menu. You can choose any file that you want its sub-menu to be reordered, like plugins.php, themes.php, tools.php etc
这篇关于Wordpress:更改管理子菜单顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!