0

I'm creating a custom taxonomy for a CPT and I need to remove the ability to create new terms for this taxonomy. I would like to know if there is a way to remove from admin menu (show_ui => false?) but keep the metabox.

I've seen some solutions hooking to the admin_menu action and removing manually but I would like to know if there is a way to tell Wordpress when I am registering this taxonomy to not put a menu for it and keep the default metabox.

Just to illustrate what I want:

+----------+----------------------------+
|  show_ui | meta_box_cb                |
+----------+----------------------------+
| true     | false                      | #=> show menu but remove metabox
| false    | false                      | #=> remove everything
| false    | true (or something truthly)| #=> this is what I want
+----------+----------------------------+

Thanks

  • Please paste the code you used to register both the CPT and custom taxonomy types. – Brad Dalton Feb 12 '14 at 19:57
0

I think the simple answer based on my testing locally is to change the value from true to false in this line of code which is included when you register taxonomy support for custom post types.

'show_ui' => false,

Here's the full code i used:

add_action( 'init', 'executive_type_taxonomy' );
function executive_type_taxonomy() {

register_taxonomy( 'portfolio-type', 'portfolio',
    array(
        'labels' => array(
            'name'          => _x( 'Types', 'taxonomy general name', 'executive' ),
            'add_new_item'  => __( 'Add New Portfolio Type', 'executive' ),
            'new_item_name' => __( 'New Portfolio Type', 'executive' ),
        ),
        'exclude_from_search' => true,
        'has_archive'         => true,
        'hierarchical'        => true,
        'rewrite'             => array( 'slug' => 'portfolio-type', 'with_front' => false ),
        'show_ui'             => false,
        'show_tagcloud'       => false,
    )
);

}

You could also remove the admin menu based on user roles and capabilities.

| improve this answer | |

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.