Skip to content

Instantly share code, notes, and snippets.

@steppohub
Created November 13, 2014 00:15
Show Gist options
  • Save steppohub/8fac780a92dc8e9bcfd2 to your computer and use it in GitHub Desktop.
Save steppohub/8fac780a92dc8e9bcfd2 to your computer and use it in GitHub Desktop.
Add custom taxonomy for a custom post type
function my_taxonomies_news() {
$labels = array(
'name' => _x( 'News Categories', 'taxonomy general name' ),
'singular_name' => _x( 'News Category', 'taxonomy singular name' ),
'search_items' => __( 'Search News Categories' ),
'all_items' => __( 'All News Categories' ),
'parent_item' => __( 'Parent News Category' ),
'parent_item_colon' => __( 'Parent News Category:' ),
'edit_item' => __( 'Edit News Category' ),
'update_item' => __( 'Update News Category' ),
'add_new_item' => __( 'Add New News Category' ),
'new_item_name' => __( 'New News Category' ),
'menu_name' => __( 'News Categories' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
);
register_taxonomy( 'news_category', 'news', $args );
}
add_action( 'init', 'my_taxonomies_news', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment