0

So sorry if this has been asked before, I've tried searching and I can't figure it out (very new to wordpress). I've got a custom post type called Members, and a custom post type called Insights. I would like a taxonomy displayed in the edit page of Insights of the list of Members. I can't seem to populate the taxonomy. Here's what I've got so far:

## MEMBERS ###
function post_members() {
    $labels = array(
        'name'               => _x( 'Members', 'post type general name' ),
        'singular_name'      => _x( 'Member', 'post type singular name' ),
        'add_new'            => _x( 'Add New', 'Member' ),
        'add_new_item'       => __( 'Add New Item' ),
        'edit_item'          => __( 'Edit Item' ),
        'new_item'           => __( 'New Item' ),
        'all_items'          => __( 'All Items' ),
        'view_item'          => __( 'View Item' ),
        'search_items'       => __( 'Search' ),
        'not_found'          => __( 'No items found' ),
        'not_found_in_trash' => __( 'No items found in the trash' ),
        'menu_name'          => __( 'Members' )
    );

    $args = array(
        'labels'              => $labels,
        'description'         => 'Members',
        'public'              => true,
        'supports'            => array( 'title', 'url' ),
        'menu_icon'           => 'dashicons-awards',
        'has_archive'         => false,
        'show_in_menu'        => true,
        'hierarchical'        => true,
    );
    register_post_type( 'members', $args );

}
add_action( 'init', 'post_members' );

## INSIGHTS ###
function post_insights() {
    $labels = array(
        'name'               => _x( 'Insights', 'post type general name' ),
        'singular_name'      => _x( 'Insights', 'post type singular name' ),
        'add_new'            => _x( 'Add New', 'Insights' ),
        'add_new_item'       => __( 'Add New Item' ),
        'edit_item'          => __( 'Edit Item' ),
        'new_item'           => __( 'New Item' ),
        'all_items'          => __( 'All Items' ),
        'view_item'          => __( 'View Item' ),
        'search_items'       => __( 'Search' ),
        'not_found'          => __( 'No items found' ),
        'not_found_in_trash' => __( 'No items found in the trash' ),
        'menu_name'          => __( 'Insights' )
    );

    $args = array(
        'labels'              => $labels,
        'description'         => 'Insights',
        'public'              => true,
        'supports'            => array( 'title', 'editor', 'member', 'thumbnail', 'featured' ),
        'menu_icon'           => 'dashicons-media-document',
        'has_archive'         => true,
        'show_in_menu'        => true,
        'rewrite'             => array('slug' => 'news-media/insights'),
        'taxonomies'          => array( 'members' ) ## this is what I'm trying to add
    );
    register_post_type( 'insights', $args );

}
add_action( 'init', 'post_insights' );

And here's what I'm trying to do to add the taxonomy to the insights page:

    register_taxonomy( 
        'members', 
        array( 'insights' ), 
        array( 
            'hierarchical'  => true, 
            'label'         => __( 'Author (Member)', CURRENT_THEME ), 
            'singular_name' => __( 'Author', CURRENT_THEME ), 
            'show_in_menu'  => false,
            'has_archive'   => false, 
            'query_var'     => true,
            'rewrite'       => array('slug' => 'news-media/insights/filter/member')
        )
    );

The box shows up ok, but it's not populated.

enter image description here

On a side note, is it possible to also remove "Add New Category"?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.