When we work with WordPress websites, the backend admin menu is an important part of an administrator's daily operations. However, the default admin menu may not fully meet everyone's needs. In this article, we will introduce two methods in detail:Manage menus using plugins and manual reordering via code.
Reordering the Admin Menu with Plugins
Using the plugin requires no coding, is easy to do and the visualization is intuitive. The following steps will help you understand how to reorder the menu using the plugin.
Step 1: Install the plug-in
We will use the Admin Menu Editor plug-in (software component)
The plugin allows drag and drop reordering of admin menus. It also provides some additional features such as editing menu names, changing access rights, etc.
- Go to the plugin directory: Log in to your WordPress dashboard and navigate to Plugins > Add New PluginThe
- Search plugin: In the search bar type "Admin Menu Editor" and find the plugin, click InstallationThe
- Activate the plug-in: After the installation is complete, click activateThe
Step 2: Reordering the menu using the plugin
- Open the menu editor: After activating the plugin, go to Settings > Menu EditorThe
- Drag and drop menu items: In the Menu Editor screen, you can see the current management menu. With a simple drag-and-drop operation, you can rearrange the menu items according to your needs.
- Customize the menu settings: Clicking on each menu item allows you to adjust their settings, such as changing the menu name, setting user permissions, and so on.
- Save changes: Once you have completed the adjustments, click on the bottom of the page Save Changes button and your customized menu will take effect.
Plug-in Functionality Advantages
- Intuitive operation: Drag-and-drop interface, easy to use.
- Fine customization options: Customizable menu names, icons, links and even permissions.
- Reduce the risk of errors: The plugin automatically handles code sections to avoid user errors due to manual coding.
Manually reorder the admin menu by code
If you don't want to do this through a plugin, or if you want more precise control over the WordPress backend, you can edit the theme's functions.php
file to achieve manual sorting. This method requires some basic coding knowledge, but avoids resource consumption and performance issues caused by plugin installation.
Step 1: Visit functions.php
- Go to the theme editor: Log in to the WordPress backend and navigate to Appearance > Theme File EditorThe
- show (a ticket)
functions.php
Documentation: In the list of theme files on the right hand side find and click on thefunctions.php
Documentation.
Step 2: Add Custom Code
exist functions.php
At the end of the file, add the following code snippet:
add_filter('custom_menu_order', 'custom_reorder_admin_menu');
add_filter('menu_order', 'custom_reorder_admin_menu');
function custom_reorder_admin_menu($menu_ord) {
If (!$menu_ord) return true;
return array(
'index.php', // Dashboard
'separator1', // separator
'edit.php?post_type=page', // Pages
'edit.php', // Posts
);
}
code interpretation
add_filter('custom_menu_order', 'custom_reorder_admin_menu');
: This code tells WordPress that you want to customize the order of the admin menu.add_filter('menu_order', 'custom_reorder_admin_menu');
: Bymenu_order
Hooks set custom order.$menu_ord
Array: This array contains the current menu items. By returning a new array, you can specify the order of each menu item.
How to further customize the menu
Menu items in the code can be adjusted as needed. For example, if you want theRemove a menu item (e.g. the Articles menu), the following code can be used:
function 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', 'remove_posts_menu');
This code will remove the "Articles" item from the admin menu.
How to Fully Customize WordPress Admin Menu
In addition to reordering the menu items, you can further customize the WordPress backend admin menu in the following ways.
Deleting menu items
By using the remove_menu_page()
function, you can completely hide some unwanted menu items. The sample code is as follows:
phpCopy codefunction remove_menus() {
remove_menu_page('edit-comments.php'); // Remove the Comments menu item
remove_menu_page('upload.php'); // Delete Media Library menu item
}
add_action('admin_menu', 'remove_menus');
By calling the remove_menu_page()
, you can hide multiple menu items.
Fully customizable user interface
On top of managing menu items, it is also possible to combine user roles and permissions to display different menu items for different users. This can be accomplished through the current_user_can()
function to ensure that only users with specific permissions can access certain menus.
summarize
Customizing the WordPress backend admin menu can help you improve your website's management efficiency, whether you use a plugin or manually add code. Plugins are suitable for beginners, with simple drag-and-drop operation and low risk, while the code approach is suitable for advanced users and can provide a more flexible customization experience.
draw attention to sth.
- Backup website: in editorial
functions.php
Be sure to back up your site before you file, in case of unexpected errors. - Test Changes: After making any changes, make sure to test the operation of the WordPress backend to confirm that the menus are working as expected.
With these methods, it's easy to customize and optimize the WordPress backend admin menu to better fit your workflow needs.