waynedunkley
9/30/2015 - 12:59 AM

Register a custom Hierarchical Taxonomy (like categories)

Register a custom Hierarchical Taxonomy (like categories)

// Register Custom Taxonomies
function custom_taxonomies() {
  // Add new taxonomy, make it hierarchical (like categories)
	$labels = array(
		'name'              => _x( 'Regions', 'taxonomy general name' ),
		'singular_name'     => _x( 'Region', 'taxonomy singular name' ),
		'search_items'      => __( 'Search Regions' ),
		'all_items'         => __( 'All Regions' ),
		'parent_item'       => __( 'Parent Region' ),
		'parent_item_colon' => __( 'Parent Region:' ),
		'edit_item'         => __( 'Edit Region' ),
		'update_item'       => __( 'Update Region' ),
		'add_new_item'      => __( 'Add New Region' ),
		'new_item_name'     => __( 'New Region' ),
		'menu_name'         => __( 'Regions' ),
	);

	$args = array(
		'hierarchical'      => true,
		'labels'            => $labels,
		'show_ui'           => true,
		'show_admin_column' => true,
		'query_var'         => true,
		'rewrite'           => array( 'slug' => 'region' ),
	);

	register_taxonomy( 'region', array( 'post_producer' ), $args );
}
add_action( 'init', 'custom_taxonomies', 0 );