Here’s my Taxonomy:
add_action( 'init', 'register_taxonomy_locations' );
function register_taxonomy_locations() {
$labels = array(
'name' => _x( 'Locations', 'locations' ),
'singular_name' => _x( 'Location', 'locations' ),
'search_items' => _x( 'Search Locations', 'locations' ),
'popular_items' => _x( 'Popular Locations', 'locations' ),
'all_items' => _x( 'All Locations', 'locations' ),
'parent_item' => _x( 'Parent Location', 'locations' ),
'parent_item_colon' => _x( 'Parent Location:', 'locations' ),
'edit_item' => _x( 'Edit Location', 'locations' ),
'update_item' => _x( 'Update Location', 'locations' ),
'add_new_item' => _x( 'Add New Location', 'locations' ),
'new_item_name' => _x( 'New Location', 'locations' ),
'separate_items_with_commas' => _x( 'Separate locations with commas', 'locations' ),
'add_or_remove_items' => _x( 'Add or remove locations', 'locations' ),
'choose_from_most_used' => _x( 'Choose from the most used locations', 'locations' ),
'menu_name' => _x( 'Locations', 'locations' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'show_admin_column' => false,
'hierarchical' => true,
'rewrite' => true,
'query_var' => true
);
register_taxonomy( 'locations', array('states', 'post', 'school'), $args );
}
And here’s my CPT:
add_action( 'init', 'register_cpt_states' );
function register_cpt_states() {
$labels = array(
'name' => _x( 'Demographics', 'states' ),
'singular_name' => _x( 'Demographic', 'states' ),
'add_new' => _x( 'Add New', 'states' ),
'add_new_item' => _x( 'Add New Demographic', 'states' ),
'edit_item' => _x( 'Edit Demographic', 'states' ),
'new_item' => _x( 'New Demographic', 'states' ),
'view_item' => _x( 'View Demographic', 'states' ),
'search_items' => _x( 'Search Demographics', 'states' ),
'not_found' => _x( 'No demographics found', 'states' ),
'not_found_in_trash' => _x( 'No demographics found in Trash', 'states' ),
'parent_item_colon' => _x( 'Parent Demographic:', 'states' ),
'menu_name' => _x( 'Demographics', 'states' ),
);
$args = array(
'labels' => $labels,
//'description' => 'Yo Whatup?',
'hierarchical' => true,
'menu_icon' => 'dashicons-location-alt',
'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes' ),
'taxonomies' => array( 'locations', 'location_types' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type( 'states', $args );
}