remove_menu_page

Home » Functions » remove_menu_page

WordPress offers a wide array of functions that are aimed at making web development much easier. One of such functions is the remove_menu_page function. As the name implies, this function is used to remove a specific menu page from the WordPress dashboard.

By default, WordPress comes with a variety of menu pages such as Dashboard, Posts, Media, Pages, and many more. However, as a developer, you may want to hide or remove some of these pages for specific users or for everyone. This is where the remove_menu_page function comes in handy.

The remove_menu_page function accepts a single parameter which is the URL slug of the page you want to remove. Once you input the URL slug of the page, the function will remove it from the WordPress dashboard.

Example Usage Code:

Let’s say we want to remove the "Tools" menu page from the WordPress dashboard. Here’s how we can do that:

function remove_tools_menu_page() {
    remove_menu_page( 'tools.php' );
}
add_action( 'admin_menu', 'remove_tools_menu_page' );

In the above code, we created a function called "remove_tools_menu_page" which uses the remove_menu_page function to remove the "tools.php" page from the WordPress dashboard. We then attached this function to the "admin_menu" action hook using the add_action function.

That’s it! With this code, the "Tools" menu page will no longer appear in the WordPress dashboard.

Learn More on WordPress.org

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