• I have created a custom post type called “protocols” and registered a few taxonomies for that custom post type to allow the customer a filterable/searchable list of posts. For some reason, the taxonomy categories are not showing up in the admin screen post list for the custom post type. screenshot here: https://demo.agexpressions.com/img/admin-screen.png

    I have used the ‘show_admin_column’ => true line when registering all the taxonomies but the columns are still blank! Hopefully someone with sharp eyes and more knowledge than me can help me diagnose this issue! Code below:

    // Creates Protocols Custom Post Type
    function protocols_init() {
        $args = array(
          'label' => 'Protocols',
            'public' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'rewrite' => array('slug' => 'protocol'),
            'query_var' => true,
            'menu_icon' => 'dashicons-book-alt',
    	'menu_position' => 5,
    	'has_archive' => true,
            'supports' => array(
                'title',
                'editor',
                'revisions',)
            );
        register_post_type( 'protocols', $args );
    }
    add_action( 'init', 'protocols_init' );
    // hook into the init action and call create_protocol_taxonomies when it fires
    add_action( 'init', 'create_protocol_taxonomies', 0 );
    
    // create three taxonomies - primary and secondary categories, and status for the post type "protocols"
    function create_protocol_taxonomies() {
    	// Add new taxonomy for Primary Category
    	$labels = array(
    		'name'              => _x( 'Primary', 'taxonomy general name' ),
    		'singular_name'     => _x( 'Primary', 'taxonomy singular name' ),
    		'search_items'      => __( 'Search Primary' ),
    		'all_items'         => __( 'All Primaries' ),
    		'menu_name'         => __( 'Primary' ),
    	);
    
    	$args = array(
    		'hierarchical'      => true,
    		'labels'            => $labels,
    		'show_ui'           => true,
    		'show_admin_column' => true,
    		'query_var'         => true,
    		'rewrite'           => array( 'slug' => 'primary' ),
    	);
    
    	register_taxonomy( 'primary', array( 'protocols' ), $args );
    
    	// Add new taxonomy for Disease Category
    	$labels = array(
    		'name'              => _x( 'Disease', 'taxonomy general name' ),
    		'singular_name'     => _x( 'Disease', 'taxonomy singular name' ),
    		'search_items'      => __( 'Search Disease' ),
    		'all_items'         => __( 'All Diseases' ),
    		'menu_name'         => __( 'Disease' ),
    	);
    
    	$args = array(
    		'hierarchical'      => true,
    		'labels'            => $labels,
    		'show_ui'           => true,
    		'show_admin_column' => true,
    		'query_var'         => true,
    		'rewrite'           => array( 'slug' => 'disease' ),
    	);
    
    	register_taxonomy( 'disease', array( 'protocols' ), $args );
    
    	// Add new taxonomy for Status
    	$labels = array(
    		'name'              => _x( 'Status', 'taxonomy general name' ),
    		'singular_name'     => _x( 'Status', 'taxonomy singular name' ),
    		'search_items'      => __( 'Search Status' ),
    		'all_items'         => __( 'All Status' ),
    		'menu_name'         => __( 'Status' ),
    	);
    
    	$args = array(
    		'hierarchical'      => true,
    		'labels'            => $labels,
    		'show_ui'           => true,
    		'show_admin_column' => TRUE,
    		'query_var'         => true,
    		'rewrite'           => array( 'slug' => 'status' ),
    	);
    
    	register_taxonomy( 'status', array( 'protocols' ), $args );
    }
Viewing 1 replies (of 1 total)
  • Thread Starter cromagrickman

    (@cromagrickman)

    Noticed something else today. If you click the “quick edit” link on a post and assign categories to it, they then show up in the columns!

    If you go to the full edit screen, the categories you just assigned are there, but if you make changes or even update without making changes, the categories disappear from the admin columns again…

    So confused, someone please take a look at my code and see if I’m doing something wrong!!

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Taxonomies not showing for custom post type’ is closed to new replies.