How to Reorder Admin Menu Items in WordPress?

If you’re looking to reorder the WordPress admin menu to make the dashboard work better for you or create a custom admin menu for different users, you’re in the right place!

We’ll go over two methods: one that’s super easy and great for beginners, and another that’s a bit more advanced if you’re up for a little coding. Let’s dive into this step-by-step guide on how to reorder the admin menu in WordPress.



Method 1: Using a Plugin (Admin Menu Editor)

One of the easiest and beginner-friendly methods to reorder the admin menu is by using the “Admin Menu Editor” plugin.

Just like any other WordPress Plugin, the installation and activating process is the same such as,

  • Install the Plugin:
  • Go to your WordPress dashboard and Navigate to Plugins > Add New.
Installing Admin Menu Editor
Installing Admin Menu Editor
  • Search for Admin Menu Editor > Click Install Now, then Activate.
  • Once activated, go to Settings > Menu Editor in your dashboard.
Menu Editor
Menu Editor
  • You’ll see a drag-and-drop interface with the current admin menu items.
  • Drag and drop the items to reorder them as you prefer.
Drag and drop interface in menu editor
Drag and drop interface in menu editor
  • You can also click on a menu item to adjust its settings, such as its name or access permissions.
Menu Editor Settings
Menu Editor Settings
  • After making your changes, click Save Changes.

Discover-the-WPOven-difference-Get-started-today

Method 2: Manually Reordering via Code

If you’d rather not rely on plugins, which can sometimes use up server resources and impact website performance, you can reorder the admin menu by adding custom code directly to your theme’s functions.php file. Here’s how you can do it:

Step 1: Access functions.php:

  • Go to Appearance > Theme Editor in your WordPress dashboard.
  • Select functions.php from the list of theme files and Open it. 
  • Now Add the following code snippet at the end of the functions.php file: 

add_filter( 'custom_menu_order', 'dgtlnk_custom_menu_order', 10, 1 );

add_filter( 'menu_order', 'dgtlnk_custom_menu_order', 10, 1 );

function dgtlnk_custom_menu_order( $menu_ord ) {

     if ( !$menu_ord ) return true;

     return array(

          'index.php', // Dashboard

          'separator1', // First separator

          'edit.php?post_type=page', // Pages

          'edit.php', // Posts

     );

}

What will the Code do?

The following code will reorder the WordPress admin menu so that the items appear in a specific order you define.

  • The first line, add_filter( ‘custom_menu_order’, ‘dgtlnk_custom_menu_order’, 10, 1 );, hooks into custom_menu_orderand lets WordPress know that you want to set a custom order for the admin menu.
  • This tells WordPress that you want to use a custom order for the admin menu. The dgtlnk_custom_menu_orderfunction will handle this ordering.
  • The second line, add_filter( ‘menu_order’, ‘dgtlnk_custom_menu_order’, 10, 1 );, hooks into menu_order.
  • This hook sets the custom order bypassing the menu items through your function, dgtlnk_custom_menu_order.
  • The function dgtlnk_custom_menu_order is defined to reorder the admin menu items.
  • It accepts one parameter, $menu_ord, which is an array of the current menu items.
  • The line if ( !$menu_ord ) return true; checks if the $menu_ord is empty or not set. If it is empty, it returns true to continue without changes.
  • The return array(…); part returns a new array with the specific order of the menu items you want:
    • ‘index.php’: This is the Dashboard link.
    • ‘separator1’: A separator line to visually break up the menu sections.
    • ‘edit.php?post_type=page’: The link for Pages.
    • ‘edit.php’: The link for Posts.

And if you want to remove the Posts Menu such as All Posts, Add New, etc.) from the WP Admin you need to add the following code to the functions.php file.

function jh_remove_posts_menu( $menu_ord ) {

    if (($key = array_search('edit.php', $menu_ord)) !== false) {

        unset($menu_ord[$key]);

    }

    return $menu_ord;

}

add_filter( 'menu_order', 'jh_remove_posts_menu', 10, 1 );

  • The jh_remove_posts_menu function is used to remove the “Posts” menu item from the admin menu.
  • It searches for the menu slug ‘edit.php’ in the list of menu items, removes it if found, and then returns the updated menu order.
  • The add_filter function hooks this custom function to the menu_order filter, allowing WordPress to apply the custom menu order when generating the admin menu.

WPOven Dedicated Hosting

Completely customizing the WordPress admin menu

Utilizing the above-mentioned functions is easy enough to reorder the menu items of your project. All you have to just follow these tips mentioned below:

Rearranging Admin menu

1. Choosing Menu Items:

   – First, decide which menu items you want to move around in the WordPress admin area. These are the options you see on the left-hand side of the dashboard, like Dashboard, Posts, Pages, etc.

2. Finding the URL Slug:

   – For each menu item you want to rearrange, you need to get its URL slug. The URL slug is the part of the URL that comes after /wp-admin/.

   – For example, if you look at the URL for the Pages menu item and it’s https://example.com/wp-admin/edit.php?post_type=page, the slug you need is edit.php?post_type=page.

3. Reordering the Menu Items:

   – Using the slugs you’ve gathered, you can specify the new order for these menu items. You will arrange these slugs in the order you want them to appear in the admin menu.

   – You can also add separators to group related items together if needed. This helps in keeping the menu organized visually.

4. Handling Unlisted Items:

   – If you choose not to include an item in your custom menu order, or if you don’t remove it from the menu entirely, it will appear below the items you’ve reordered.

   – For example, if you only reorder the top few items in the menu, the rest of the items will stay in their original order below your custom items.

Removing Menu Items

1. Using remove_menu_page:

   – To completely remove a menu item from the admin menu, use the remove_menu_page function with the slug of the page you want to hide.

   – For instance, if you want to remove the Comments menu item, you use remove_menu_page('edit-comments.php'). This tells WordPress to hide that particular menu item.

2. Removing Multiple Items:

   – If you need to remove more than one menu item, you can call the remove_menu_page function multiple times, each time with a different slug for the page you want to remove.

   – For example, to remove both the Comments and the Media Library items, you would use remove_menu_page('edit-comments.php') and remove_menu_page('upload.php') in your code.

Tips:

  • Backup Before Changes: Always back up your website before making changes to the functions.php file or installing new plugins.
  • Test the Changes: After reordering, navigate through the admin menu to ensure everything is functioning as expected.

Summary

When we think about website management, it’s easy to focus solely on creating content for visitors. But what about the backend? It’s often overlooked even though a well-organized backend can make your tasks a lot easier.

One way to improve your backend experience is by customizing the WordPress dashboard. Imagine having all your important shortcuts, charts, and tools like Google Analytics right at your fingertips. Plus, adding to-do lists can help you stay organized and keep track of your content ideas and deadlines.

Have you explored the “WordPress Admin Menu Editor” plugin? It allows you to tweak the admin menu to suit your workflow. Is it user-friendly enough? Should WordPress have built-in admin menu editing? These small adjustments can turn the backend into a space that’s perfectly tailored to how you work, making your job a lot more manageable.


Leave a Reply

Your email address will not be published. Required fields are marked *