search ]

Reorder the Admin Menu in WordPress

A short snippet that lets you change the order of the menu in the WordPress dashboard. Simply choose the order you want in the $reordered_items array. You can use var_dump($menu_order) to find all menu items.

Items will appear under the top-level item (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) {
 
  $reordered_items = array(
    'edit.php?post_type=page',
    'edit.php'
  );
 
  $reordered_items_insertion_point = 'index.php';
 
  $filtered_menu_order = array_diff($menu_order, $reordered_items);
 
  $new_menu_order = array();
 
  foreach($filtered_menu_order as $menu_item) {
    $new_menu_order[] = $menu_item;
 
    if($menu_item === $reordered_items_insertion_point) {
      $new_menu_order = array_merge($new_menu_order, $reordered_items);
    }
  }
 
  return $new_menu_order;
}

This uses a WordPress filter. Learn more in WordPress Hooks Explained.

Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo