I've created a custom non-hierarchical taxonomy and changed it to display as check boxes instead of a tag cloud. However when I am in the post editor and select on of the available tags then update the post something strange happens. The tag is now saved as the tag ID number and the Tag ID number shows up as a checked checkbox in the Tags metabox.
Here is my code for the Taxonomy:
add_action( 'init', 'create_cuturalmaptags_taxonomy', 0 );
function create_cuturalmaptags_taxonomy() {
$labels = array(
'name' => _x( 'Tags', 'taxonomy general name' ),
'singular_name' => _x( 'Tag', 'taxonomy singular name' ),
'search_items' => __( 'Search Tags' ),
'all_items' => __( 'All Tags' ),
'parent_item' => __( 'Parent Tag' ),
'parent_item_colon' => __( 'Parent Tag:' ),
'edit_item' => __( 'Edit Tag' ),
'update_item' => __( 'Update Tag' ),
'add_new_item' => __( 'Add New Tag' ),
'new_item_name' => __( 'New Tag Name' ),
'menu_name' => __( 'Tags' ),
);
register_taxonomy('cuturalmap-tags', array('post'), array(
'hierarchical' => false,
'meta_box_cb' => 'post_categories_meta_box',
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'cuturalmap-tags' ),
));
}
Here's the example of what's happening. When I go to edit the post and select the tags I want it looks normal.
But once I update the post the tags look like this:
I confirmed in the tag manager that the number is the ID of the tag I created. Any reason why this is happening and how I can fix it?
Here is my code for the CPT where the 'culturalmap-tags' gets called.
// Cultural Mapping Custom Post Type
function culturalmap_post_type() {
$labels = array(
'name' => _x( 'Cultural Map', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Cultural Map', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Cultural Mapping', 'text_domain' ),
'parent_item_colon' => __( 'Parent Cultural Map:', 'text_domain' ),
'all_items' => __( 'All Cultural Maps', 'text_domain' ),
'view_item' => __( 'View Post', 'text_domain' ),
'add_new_item' => __( 'Add New Cultural Map', 'text_domain' ),
'add_new' => __( 'Add New', 'text_domain' ),
'edit_item' => __( 'Edit Post', 'text_domain' ),
'update_item' => __( 'Update Cultural Map', 'text_domain' ),
'search_items' => __( 'Search Cultural Maps', 'text_domain' ),
'not_found' => __( 'Not found', 'text_domain' ),
'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ),
);
$args = array(
'label' => __( 'Cultural Map', 'text_domain' ),
'description' => __( 'Post Type Description', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'custom-fields' ),
'taxonomies' => array( 'cultural-mapping', 'cuturalmap-tags' ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-site',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
'rewrite' => array('slug' => 'cultural-map'),
);
register_post_type( 'culturalmap', $args );
}
// Hook into the 'init' action
add_action( 'init', 'culturalmap_post_type', 0 );
post_categories_meta_box
is for hierarchical taxonomies; yours is non-hierarchical. If you change (or remove) that parameter, does that fix the problem? Alternatively, are there any plugins (or theme) you have running that could be modifying metabox functionality?