Detailed Guide: How to Customize and Reorder WordPress Admin Menu via Plugin or Code

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.

Detailed Guide: How to Customize and Reorder WordPress Admin Menu via Plugin or 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)

Detailed Guide: How to Customize and Reorder WordPress Admin Menu via Plugin or Code

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.

  1. Go to the plugin directory: Log in to your WordPress dashboard and navigate to Plugins > Add New PluginThe
  2. Search plugin: In the search bar type "Admin Menu Editor" and find the plugin, click InstallationThe
  3. Activate the plug-in: After the installation is complete, click activateThe

Step 2: Reordering the menu using the plugin

  1. Open the menu editor: After activating the plugin, go to Settings > Menu EditorThe
Detailed Guide: How to Customize and Reorder WordPress Admin Menu via Plugin or Code
  1. 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.
Detailed Guide: How to Customize and Reorder WordPress Admin Menu via Plugin or Code
  1. 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.
Detailed Guide: How to Customize and Reorder WordPress Admin Menu via Plugin or Code
  1. 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

  1. Go to the theme editor: Log in to the WordPress backend and navigate to Appearance > Theme File EditorThe
  2. show (a ticket) functions.php Documentation: In the list of theme files on the right hand side find and click on the functions.php Documentation.
Detailed Guide: How to Customize and Reorder WordPress Admin Menu via Plugin or Code

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');: By menu_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

Detailed Guide: How to Customize and Reorder WordPress Admin Menu via Plugin or Code

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.

Detailed Guide: How to Customize and Reorder WordPress Admin Menu via Plugin or Code

draw attention to sth.

  1. Backup website: in editorial functions.php Be sure to back up your site before you file, in case of unexpected errors.
  2. 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.


Contact Us
Can't read the article? Contact us for a free answer! Free help for personal, small business sites!
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: info@361sale.com
Working hours: Monday to Friday, 9:30-18:30, holidays off
Posted by photon fluctuations, retweeted with attribution:https://www.361sale.com/en/20891/

Like (2)
Previous September 28, 2024 11:02 am
Next September 29, 2024 am10:24

Recommended

Leave a Reply

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

Contact Us

020-2206-9892

QQ咨询:1025174874

E-mail: info@361sale.com

Working hours: Monday to Friday, 9:30-18:30, holidays off

Customer Service