Auto register 'category' for any custom post type
-
Adding the following in
add_meta_boxes
enables the category taxonomy for any custom post type.foreach(get_post_types() as $post_type) { $exclude = array("wp-types-group", "wp-types-user-group", "post", "page", "attachment", "revision", "nav_menu_item"); if ( in_array($post_type, $exclude) ) continue; if (!is_object_in_taxonomy($post_type, 'category')){ register_taxonomy_for_object_type('category', $post_type); } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Auto register 'category' for any custom post type’ is closed to new replies.