Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Remove custom post type submenu pages.
function tw_remove_menu_pages() {
// remove testimonials menu section
// remove_menu_page( 'edit.php?post_type=testimonials-widget' );
// remove categories
remove_submenu_page( 'edit.php?post_type=testimonials-widget', 'edit-tags.php?taxonomy=category&amp;post_type=testimonials-widget' );
// remove tags
remove_submenu_page( 'edit.php?post_type=testimonials-widget', 'edit-tags.php?taxonomy=post_tag&amp;post_type=testimonials-widget' );
// remove settings
remove_submenu_page( 'edit.php?post_type=testimonials-widget', 'testimonialswidget_settings' );
add_action( 'admin_menu', 'tw_remove_menu_pages', 999 );
Copy link

emfluenceindia commented Jun 28, 2017

How do I remove a sub-menu with link http://vagrant.local/wp/wp-admin/admin.php?page=home_settings_page ?
I tried remove_submenu_page( 'admin.php', 'yrc_home_settings_page' ); but that didn't work.

Copy link

jimmy89Li commented Aug 17, 2017

You need to find out the parent menu slug, used when added the submenu:
add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function );

Then use this in your functions.php replacing accordingly:

// Remove submenus
    function remove_submenu() {
        remove_submenu_page( '$parent_slug', '$menu_slug' );
add_action( 'admin_menu', 'remove_submenu', 999 );

Copy link

Korveld commented Apr 11, 2020

Awesome! you're a life saver) thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment