Home » Functions » remove_submenu_page

If you’re a WordPress developer, you know that managing the admin menu is crucial. Sometimes you may want to remove a submenu page, and this is where the remove_submenu_page function comes in handy.

This function allows you to remove a submenu page from the admin menu. You can use it to clean up cluttered menus or hide pages that are not needed.

The syntax for remove_submenu_page is straightforward. You’ll need to specify the parent menu slug and the submenu slug you want to remove. The function returns true if the submenu page was successfully removed and false otherwise.

Here’s an example usage code:

function remove_my_submenu_page() {
    remove_submenu_page( 'my-parent-menu-slug', 'my-submenu-slug' );
add_action( 'admin_menu', 'remove_my_submenu_page' );

In this example, we’re using the remove_submenu_page function to remove the "my-submenu-slug" page from the "my-parent-menu-slug" parent menu. The function is hooked to the admin_menu action to ensure that it runs when the admin menu is being created.

In conclusion, the remove_submenu_page function is a useful tool for managing the WordPress admin menu. It’s easy to use and can help you keep your menus organized.

Learn More on

Register an account to save your snippets or go Pro to get more features.