0

I've been trying a lot of things so far and investigated core inside out, but couldn't find a way that allows me to add the submenu item, but doesn't add the meta box for a custom taxonomy.

The Menu item

// From: ~/wp-admin/menu.php
// That is the file that builds the menu and submenu entries.
// This is the part, where it adds the submenu items for taxonomies.
// This gets repeated for every (custom) post type menu entry.
$i = 15;
foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
    if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) )
        continue;

    $submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );
}
unset($tax);

The Meta Box

// From: ~/wp-admin/edit-form-advanced.php
// That is the file, that shows the content of a post type "edit" screen
// all taxonomies. Here it adds some meta boxes for taxonomies
foreach ( get_object_taxonomies($post_type) as $tax_name ) {
    $taxonomy = get_taxonomy($tax_name);
    if ( ! $taxonomy->show_ui )
        continue;

    $label = $taxonomy->labels->name;

    if ( !is_taxonomy_hierarchical($tax_name) )
        add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name ));
    else
        add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name ));
}

The public argument seems to only affect the query. The only factor, that I can see being responsible for both, adding the menu entry, as well as the meta box, is the show_ui argument.

Please proof me wrong. Thanks.

  • 2
    I think your stuck with using remove_meta_box, the admin menu is a wild beast. Maybe a trac ticket is in order to add something like show_meta => array(bunch of posts) – Wyck Aug 10 '12 at 3:54
  • @Wyck I'm not completely sure what will happen with happen with the menu with 3.5 as scribu is still working on a trac ticket "for a better structure of admin $menu". I guess it will be something like get_current_screen();. Maybe you want to make a starting point with an answer and get a trac ticket at the end? – kaiser Aug 10 '12 at 13:33
0

As per le comment.

function remove_artist_meta() {
    remove_meta_box( '{taxonomy name}', 'post', 'side' );
}

add_action( 'admin_menu' , 'remove_artist_meta' );

The Admin menu has been always difficult to deal with, some help here would be nice: http://core.trac.wordpress.org/ticket/12718

But I think that this could be added a a parameter to register_taxonomy. http://core.trac.wordpress.org/ticket/21543

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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