可以使用十进制值(作为字符串)。例如,我在菜单的最后一个位置(100001、100002、100003)放置了一些自定义帖子类型。
然后,只需将此代码移动到帖子上方和仪表板下方。
function reorder_admin_menu() {
global $menu;
// Add one separator
$menu["3.1"] = array(
0 => \'\',
1 => \'read\',
2 => \'separator_\' . "anything_unique",
3 => \'\',
4 => \'wp-menu-separator\'
);
// I have put my menu items waay at the end (exactly these values), so move them up
$menu["3.2"] = $menu[100001];
$menu["3.3"] = $menu[100002];
$menu["3.4"] = $menu[100003];
unset($menu[100001]);
unset($menu[100002]);
unset($menu[100003]);
// move Media menu (position 10) item to front, in the same group
$menu["3.5"] = $menu[10];
unset($menu[10]);
// Debug: ksort($menu); error_log( var_export( $menu, true ) );
}
add_action( \'admin_menu\', \'reorder_admin_menu\', 999 );