WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to retain tag taxonomy for a single custom post type, but am struggling with it.

Is there a way to remove this meta box for everything BUT?

remove_meta_box('tagsdiv-post_tag', 'post', 'normal');

Will remove the tags from normal posts (desired), but it means they're also removed from ALL custom post types. I can remove the meta box for individual custom post types, like so:

remove_meta_box('tagsdiv-post_tag', 'cars', 'normal');

remove_meta_box('tagsdiv-post_tag', 'hotels', 'normal');


But that means I have to leave tags available on normal posts (undesired).

So I guess I want something like this, to remove the meta box from everything apart from (e.g.) airports:

remove_meta_box('tagsdiv-post_tag', '!airports', 'normal');

Any ideas?

share|improve this question
Do you just want to remove the meta box but not the tags taxonomy of these CPTs? Also: Have you tried removing it everywhere and then just adding it back for this one CPT? – kraftner Jun 6 '14 at 14:58
Have you tried using Advanced Custom Fields? It is THE most incredible plugin you will ever use for Custom Fields and once you have created your Custom Post Type, you have the option of switching off certain meta boxes. – SixfootJames Jun 6 '14 at 14:59
I'm using ACF, but it doesn't help with tags, unless all you need to do is select from a pre-defined list of tags - I looked into this first :) @kraftner - this would be fine - is there a true 'add_meta_box' for this context? Docs seemed to indicate it's usage was different – Nathan Hornby Jun 6 '14 at 15:08
up vote 0 down vote accepted

Why not just turn off the default tags capability then register a tags taxonomy specific to the custom post type?


    'label'        => __( 'Tags' ),
    'rewrite'      => false,
    'hierarchical' => false,
    'capabilities' => array( 'edit_terms' => 'manage_categories' )
share|improve this answer
This is technically an improvement - not quite what I asked for - but it is the best way to achieve what I need so I'm going to mark this is correct. For anyone that needs to do exactly what I requested then @The Sufi's answer does the job (with my correction). Thanks Joey, works like a charm! – Nathan Hornby Jun 10 '14 at 15:02

You need to check either the current post is airports or not.

This can be done like this:

function custom_remove_tag_box() {
    global $current_screen;
    if ( $current_screen->post_type != 'airports' ) {
        remove_meta_box('tagsdiv-post_tag', 'post', 'normal');
add_action('admin_head', 'custom_remove_tag_box');

Tested and working.

share|improve this answer
Ah, simple as that, thanks! I'm just leaving the office for the weekend (bad timing) but will be picking this up again Monday, so will report back then ;) – Nathan Hornby Jun 6 '14 at 15:29
This cannot work. admin_init does not pass a WP_Post object. – toscho Jun 6 '14 at 15:43
@toscho Thanks for pointing out. I have updated my code, and looks like it's working for me (tested). – тнє Sufi Jun 6 '14 at 19:54
Replacing add_action('admin_head', 'custom_remove_tag_box'); with add_action('admin_menu', 'custom_remove_tag_box'); got it working. – Nathan Hornby Jun 10 '14 at 14:56

You can achieve removing metaboxes from all post type screens except specific ones. This is how I done it. Might be a bit overrated, lol

Firstly, you will need to get a list of all public post type registered. This is done by using get_post_types. You will need to use the parameter 'public' => true, otherwise all post types will be returned, which is unnecessary.

Secondly, you need to remove or exclude the post type you don't want the metabox to be removed from.

Thirdly, you need to pass the returned list of post type names to the remove_meta_box() function to remove the specific meta box from these post type screens. This function can be used to remove any meta boxes conditionally

if (is_admin()) :
function my_remove_meta_boxes() {
    if( current_user_can('manage_options') ) {
    $custom_post_types = get_post_types( array( 'public' => true ), 'objects');

        foreach ( $custom_post_types as $custom_post_type ) {

            $exclude = array( 'information' ); //<---Replace information with your own post type

            if( TRUE === in_array( $custom_post_type->name, $exclude ) )

            $posttypes = $custom_post_type->name;

            remove_meta_box('tagsdiv-post_tag', $posttypes, 'normal');

add_action( 'admin_menu', 'my_remove_meta_boxes' );
share|improve this answer
Definitely a tad over complex :) – Nathan Hornby Jun 10 '14 at 15:04
Hahaha, thought so. Great that one of the other answers helped :-) – Pieter Goosen Jun 10 '14 at 15:05
Thanks for your help anyway! – Nathan Hornby Jun 10 '14 at 15:09

Your Answer


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.