Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am not sure if it is much different for any page but I am wondering how to remove a metabox from the appearance>menu page without having to go into the wordpress core files and remove it. Is there something I can do to override it so it doesn't appear both on the page and on the screen options menu?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

By inspecting the file /wp-admin/nav-menus.php we can see that these meta-boxes:

metaboxes

are rendered with:

<?php do_meta_boxes( 'nav-menus', 'side', null ); ?>

The file /wp-admin/includes/nav-menu.php contains the corresponding add_meta_box() calls and from that we can construct the relevant removal code:

function custom_remove() {      
    remove_meta_box('nav-menu-theme-locations', 'nav-menus', 'side'); 
    remove_meta_box('add-custom-links', 'nav-menus', 'side'); 
    remove_meta_box('add-post', 'nav-menus', 'side'); 
    remove_meta_box('add-page', 'nav-menus', 'side'); 
    remove_meta_box('add-category', 'nav-menus', 'side'); 
}
add_action('admin_head-nav-menus.php', 'custom_remove');

where we can use for example the admin_head-nav-menus.php action since it is called before these meta-boxes are rendered.

If you have a custom post type (or a custom taxonomy) then you can remove it's meta-box with

   remove_meta_box( 'add-xxx' , 'nav-menus' , 'side' ); 

where xxx is the corresponding name.

You can further check out the functions wp_nav_menu_setup(), wp_nav_menu_post_type_meta_boxes() and wp_nav_menu_taxonomy_meta_boxes() to see how the meta-boxes are added.

share|improve this answer
    
Great! Thank you for the detailed answer I really appreciate it. –  user1632018 May 1 '13 at 22:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.