• Hi, I’ve added a custom taxonomy (‘artist’) to my post using register_taxonomy function in functions.php.

    $labels = array(
        'name' => _x( 'Add an Artist', 'taxonomy general name' ),
        'singular_name' => _x( 'Artist', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Artists' ),
        'popular_items' => __( 'Popular Artists' ),
        'all_items' => __( 'All Artists' ),
        'parent_item' => null,
        'parent_item_colon' => null,
        'edit_item' => __( 'Edit Artist' ),
        'update_item' => __( 'Update Artist' ),
        'add_new_item' => __( 'Add New Artist' ),
        'new_item_name' => __( 'New Artist Name' ),
        'separate_items_with_commas' => __( 'Separate artists with commas' ),
        'add_or_remove_items' => __( 'Add or remove artists' ),
        'choose_from_most_used' => __( 'Choose from the most used artists' )
      ); 
    
      register_taxonomy('artist','post',array(
        'hierarchical' => false,
        'labels' => $labels,
    	'public' => true,
    	'show_tagcloud' => true,
        'show_ui' => true,
        'query_var' => 'artist',
        'rewrite' => array( 'slug' => 'artist' ),
      ));

    However, I need to hide the custom taxonomy metabox from some of my new post screens. I’ve tried to use remove_meta_box( ‘artist’ , ‘post’ , ‘normal’ ); wrapped in an if statement, however, with or without the if statement the metabox remains.

    function remove_artist_meta() {
    	remove_meta_box( 'artist' , 'post' , 'normal' );
    }
    add_action( 'admin_menu' , 'remove_artist_meta' );

    Does anyone know of the first parameter for remove_meta_box is correct as artist, or would it be something else??

Viewing 8 replies - 1 through 8 (of 8 total)
  • you must change in register_taxonomy:
    'show_ui' => false,

    @serdomonik,

    That is correct. But I can imagine that someone wants to remove the Metabox from the Post Edit itself, but not from the Admin panel as an seperate menu.

    Actually I am looking for this myself. I need the Taxonomy as an seperate menu item in my Admin menu, but not as an UI Metabox in the Post editor.

    Any way to fix this functionality?

    You’re almost there. First of all, the context for boxes added to the side of the edit page (where the taxonomies typically show up) is ‘side’ (not ‘normal’). Second, the taxonomy edit boxes are registered as tagsdiv-{taxonomy name}. So, this works for me (using your artist taxonomy as an example):

    function remove_artist_meta() {
    	remove_meta_box( 'tagsdiv-artist', 'post', 'side' );
    }
    
    add_action( 'admin_menu' , 'remove_artist_meta' );

    nice– actually i found this out by firebuggin’ the admin screen. but i lost track of this thread, thank you for taking the time to post the answer.

    Found something about the solution: it removes taxonomy metaboxes that behave like tags but not categories.

    I noticed the same as @funkatronic. Non-hierarchical taxonomies can be removed using ‘tagsdiv-custom_taxonomy_slug’, but hierarchical taxonomies will not be removed.

    Tried ‘categorydiv-custom_taxonomy_slug’ as well but no success.

    anyone have a solution?

    Found a solution a while ago that I forgot to post here. Hierarchical taxonomy boxes can be removed by using custom_taxonomy_slugdiv

    that’s great @funkatronic. very useful.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Remove metabox for custom taxonomy’ is closed to new replies.