How to Move a WordPress Admin Submenu Item from One Parent to Another

In WordPress, the admin menu is essential for managing plugins, settings, themes, and other site features.

However, sometimes the default arrangement doesn’t suit a site’s needs, and you may want to move submenu items to better organize the admin interface.

For example, you might want to move a submenu item from one parent menu to another for quicker access or to declutter specific areas.

This guide shows you how to relocate a submenu item in the WordPress admin menu using custom code.


Why Rearrange Submenu Items in the WordPress Admin Menu?

Moving a submenu item to a different parent can help streamline your workflow, making it easier to navigate and manage your website.

For instance, if a plugin’s submenu item is buried under “Settings,” but you access it frequently, moving it to a more prominent parent, such as “Dashboard” or “Appearance,” can save time.

This reorganization is particularly beneficial for multisite administrators or users who manage several sites from a single dashboard.


Steps to Move a Submenu Item in the WordPress Admin Menu

To move a submenu item, we’ll need to use custom code. The following steps will walk you through how to create this functionality using PHP in your WordPress theme’s functions.php file or a custom plugin.

1. Identify the Submenu Item to Move

Before making any changes, identify the submenu item you want to move. Each menu and submenu in WordPress has a unique slug that WordPress uses to organize and display these items in the admin area. You can find submenu slugs by inspecting the URL of the desired submenu item in the WordPress dashboard.

For example, the submenu slug for “Permalinks” under “Settings” is options-permalink.php, and the parent menu slug for “Settings” is options-general.php.

2. Use remove_submenu_page() to Remove the Original Submenu

To move a submenu item, you must first remove it from its current location. This is done with the remove_submenu_page() function, which removes the item from its original parent menu.

Add the following code to your theme’s functions.php file or a custom plugin file:

function custom_move_submenu_item() {
remove_submenu_page(‘options-general.php’, ‘options-permalink.php’);
}
add_action(‘admin_menu’, ‘custom_move_submenu_item’, 999);

In this example:

  • options-general.php is the slug for the parent menu (Settings).
  • options-permalink.php is the slug for the submenu item (Permalinks).

This function removes the “Permalinks” submenu from “Settings.”

3. Use add_submenu_page() to Add the Submenu Item to a New Parent

Once you’ve removed the submenu item from its original parent, the next step is to add it to a new parent menu using the add_submenu_page() function.

Here’s an example code to move the “Permalinks” submenu to the “Appearance” menu:

function custom_move_submenu_item() {
remove_submenu_page(‘options-general.php’, ‘options-permalink.php’); // Remove from Settings
add_submenu_page(‘themes.php’, ‘Permalinks’, ‘Permalinks’, ‘manage_options’, ‘options-permalink.php’);
}
add_action(‘admin_menu’, ‘custom_move_submenu_item’, 999);

In this code:

  • themes.php is the slug for the new parent menu (Appearance).
  • The 'Permalinks' label appears as the submenu title.
  • manage_options defines the capability required to access this submenu, typically set to manage_options for settings-related items.
  • 'options-permalink.php' is the slug for the actual submenu item.

With this code, “Permalinks” now appears as a submenu item under “Appearance” instead of “Settings.”

4. Verify the Change in the WordPress Admin Menu

After adding the code, refresh your WordPress dashboard to verify that the submenu item has been successfully moved to its new parent menu. If everything was set up correctly, you should see the submenu item under its new location in the admin menu.


Additional Tips and Considerations

  1. User Permissions: Be cautious with permissions when adding submenu items to new locations. The capability parameter in the add_submenu_page() function determines which user roles can access the menu. Use appropriate capabilities like manage_options or edit_posts to ensure access control.
  2. Testing in a Staging Environment: Before making changes to the live site, test the code in a staging environment. This approach allows you to avoid unexpected issues or conflicts with other plugins.
  3. Backup the Functions File: Always make a backup of your functions.php file before editing it. Small syntax errors in PHP can cause the WordPress site to crash, so having a backup ensures you can quickly restore the file if needed.
  4. Using a Custom Plugin: For larger sites or frequent changes, consider using a custom plugin instead of editing functions.php. This approach keeps customizations organized and can be easily enabled or disabled.
  5. Compatibility with Plugin Updates: If you’re moving submenu items created by plugins, note that plugin updates may override the customizations. Be sure to check your changes after plugin updates and reapply them if necessary.

Conclusion

Moving submenu items in the WordPress admin menu can help you customize the dashboard and optimize your workflow. By following these steps, you can easily rearrange the admin menu to better suit your needs. This flexibility allows you to create a streamlined, organized experience, whether for yourself, clients, or users.

Have questions or need help with customization? Leave a comment below, and let’s discuss ways to make the WordPress admin menu work better for you!