Here’s a quick snippet to reorder the admin menu in WordPress.
Simply specify the order you want in the $reordered_items
array (you can var_dump($menu_order)
to find all available menu items.
The items will be inserted under the topmost link (Dashboard).
add_filter('menu_order', 'reorder_admin_menu', 999);
/**
* Reorders admin menu to match the wanted order
*
* @param $menu_order
* @return mixed
*/
function reorder_admin_menu($menu_order) {
//Example. Puts "Pages" above "Posts".
$reordered_items = array(
'edit.php?post_type=page',
'edit.php'
);
//This is where we will insert our reordered items
$reordered_items_insertion_point = 'index.php';
//Remove items we are supposed to reorder
$filtered_menu_order = array_diff($menu_order, $reordered_items);
//Init new order
$new_menu_order = array();
//Loop all current menu items
foreach($filtered_menu_order as $menu_item) {
//Add to array
$new_menu_order[] = $menu_item;
//Our trigger? Let's go!
if($menu_item === $reordered_items_insertion_point) {
//Add in our reordered items
$new_menu_order = array_merge($new_menu_order, $reordered_items);
}
}
return $new_menu_order;
}