3
votes

I have created a Custom Post Type called user-story. The $args looks like this:

$args = array(
   'labels' => $labels,
   'hierarchical' => true,
   'description' => 'description',
   'taxonomies' => array('category', 'story-type', 'genre'),
   'show_ui' => true,
   'show_in_menu' => true,
   'menu_position' => 5,
   'menu_icon' => 'http://webmaster.webmastersuccess.netdna-cdn.com/wp-content/uploads/2015/03/pencil.png',
   'public' => true,
   'has_archive' => true,
   'query_var' => true,
   'capability_type' => 'post',
   'supports' => $supports,
   'rewrite' => $rewrite,
   'register_meta_box_cb' => 'add_story_metaboxes' );

register_post_type('user_story', $args);

The problem is in line 'taxonomies' => array('category', 'story-type', 'genre'),. I cannot see my taxonomies story-type and genre in Add New Story page in admin. Only category is showing up.

Both story-type and genre are custom taxonomies. I deactivated CPT plugin (user_story) and then reactivated it. But still above custom taxonomies are not coming up.

Both custom taxonomies are registered through plugins and they are visible in Admin menu. Terms registered under these taxonomies are also showing up in their respective list pages.

Screenshot-1: List of terms registered in taxonomy story-type

enter image description here

Screenshot-2: List of terms registered in taxonomy genre

enter image description here

Screenshot-3: Add New Story page - none of the above taxonomies other than only the built-in taxonomy category is listed

enter image description here

I referenced this.

1

1 Answers

4
votes

This one should help: https://developer.wordpress.org/reference/functions/register_taxonomy/

Place this code in your functions.php file and custom taxonomies should be added to your custom post type.

<?php
add_action( 'init', 'create_user_story_tax' );

function create_user_story_tax() {

    /* Create Genre Taxonomy */
    $args = array(
        'label' => __( 'Genre' ),
        'rewrite' => array( 'slug' => 'genre' ),
        'hierarchical' => true,
    )

    register_taxonomy( 'genre', 'user-story', $args );
    
    /* Create Story Type Taxonomy */
    $args = array(
            'label' => __( 'Story Type' ),
            'rewrite' => array( 'slug' => 'story-type' ),
            'hierarchical' => true,
        )

    register_taxonomy( 'story-type', 'user-story', $args );
    
}
?>