The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Remove metabox for custom taxonomy (9 posts)

  1. jadedstudio
    Posted 6 years ago #

    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' )
        '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??

  2. serdominik
    Posted 5 years ago #

    you must change in register_taxonomy:
    'show_ui' => false,

  3. opicron
    Posted 5 years ago #


    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?

  4. handsofaten
    Posted 5 years ago #

    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' );
  5. opicron
    Posted 5 years ago #

    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.

  6. Manny Fleurmond
    Posted 5 years ago #

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

  7. Ken Dirschl
    Posted 5 years ago #

    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?

  8. Manny Fleurmond
    Posted 5 years ago #

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

  9. Ken Dirschl
    Posted 5 years ago #

    that's great @Funkatronic. very useful.

Topic Closed

This topic has been closed to new replies.

About this Topic