Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A Wordpress snippet to register a new taxonomy.
<?php
add_action( 'init', 'register_new_taxonomy' );
function register_new_taxonomy() {
$labels = array(
'name' => _x( 'plural taxonomy', 'Taxonomy general name', 'text_domain' ),
'singular_name' => _x( 'single taxonomy', 'Taxonomy singular name', 'text_domain' ),
'search_items' => __( 'Search plural taxonomy', 'text_domain' ),
'popular_items' => __( 'Popular plural taxonomy', 'text_domain' ),
'all_items' => __( 'All plural taxonomy', 'text_domain' ),
'parent_item' => __( 'Parent single taxonomy', 'text_domain' ),
'parent_item_colon' => __( 'Parent single taxonomy', 'text_domain' ),
'edit_item' => __( 'Edit single taxonomy', 'text_domain' ),
'update_item' => __( 'Update single taxonomy', 'text_domain' ),
'add_new_item' => __( 'Add New single taxonomy', 'text_domain' ),
'new_item_name' => __( 'New single taxonomy Name', 'text_domain' ),
'add_or_remove_items' => __( 'Add or remove plural taxonomy', 'text_domain' ),
'choose_from_most_used' => __( 'Choose from most used plural taxonomy', 'text_domain' ),
'menu_name' => __( 'single taxonomy', 'text_domain' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => true,
'hierarchical' => true,
'show_tagcloud' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'query_var' => true,
'capabilities' => '',
);
register_taxonomy( 'taxonomy-id', array( 'post' ), $args );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment