Menu

Add New Custom texonomy

February 4, 2014 - wordpress

function add_custom_taxonomies() {
// Add new “topics” taxonomy to Posts
register_taxonomy(‘topics’, ‘page’, array(
// Hierarchical taxonomy (like categories)
‘hierarchical’ => true,
// This array of options controls the labels displayed in the WordPress Admin UI
‘labels’ => array(
‘name’ => _x( ‘topics’, ‘taxonomy general name’ ),
‘singular_name’ => _x( ‘topic’, ‘taxonomy singular name’ ),
‘search_items’ => __( ‘Search topics’ ),
‘all_items’ => __( ‘All topics’ ),
‘parent_item’ => __( ‘Parent topic’ ),
‘parent_item_colon’ => __( ‘Parent topic:’ ),
‘edit_item’ => __( ‘Edit topic’ ),
‘update_item’ => __( ‘Update topic’ ),
‘add_new_item’ => __( ‘Add New topic’ ),
‘new_item_name’ => __( ‘New topic Name’ ),
‘menu_name’ => __( ‘topics’ ),
),
// Control the slugs used for this taxonomy
‘rewrite’ => array(
‘slug’ => ‘topics’, // This controls the base slug that will display before each term
‘with_front’ => false, // Don’t display the category base before “/locations/”
‘hierarchical’ => true // This will allow URL’s like “/locations/boston/cambridge/”
),
));
}
add_action( ‘init’, ‘add_custom_taxonomies’, 0 );

Leave a Reply