[英]Wordpress: Change admin submenu order
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'),
但问题是它在wp子菜单结束时出现(即,在'标签'之后),
How to change the order of this custom admin page submenu entry to appear after 'Add new' ? 如何更改此“自定义管理页面”子菜单项的顺序以在“添加新”后显示?
I'm using this function to register my sub-menu under edit.php(Posts menu) 我正在使用此功能在edit.php(帖子菜单)下注册我的子菜单
add_submenu_page(
'edit.php',
"my custom submenu",
"my custom submenu",
CAPABILITY,
'my_custom_submenu',
"scrollcore_newsroom_articles"
);
Found the solution, just need to add this function to your functions.php 找到解决方案,只需要将这个函数添加到你的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;
}
Here by choosing edit.php, I'm targeting 'Posts' menu. 在这里选择edit.php,我的目标是“帖子”菜单。 You can choose any file that you want its sub-menu to be reordered, like plugins.php, themes.php, tools.php etc
您可以选择任何您希望其子菜单重新排序的文件,如plugins.php,themes.php,tools.php等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.