Last active
August 29, 2015 14:01
-
-
Save yellowberri-snippets/f45ee3cad913629286f4 to your computer and use it in GitHub Desktop.
PHP: WP: Custom Taxonomy Definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Genre Custom Taxonomy Definition | |
function create_book_taxonomies() { | |
// Add new taxonomy, make it hierarchical (like categories) | |
$labels = array( | |
'name' => _x( 'Genres', 'taxonomy general name' ), | |
'singular_name' => _x( 'Genre', 'taxonomy singular name' ), | |
'search_items' => __( 'Search Genres' ), | |
'all_items' => __( 'All Genres' ), | |
'parent_item' => __( 'Parent Genre' ), | |
'parent_item_colon' => __( 'Parent Genre:' ), | |
'edit_item' => __( 'Edit Genre' ), | |
'update_item' => __( 'Update Genre' ), | |
'add_new_item' => __( 'Add New Genre' ), | |
'new_item_name' => __( 'New Genre Name' ), | |
'menu_name' => __( 'Genre' ), | |
); | |
$args = array( | |
'hierarchical' => true, | |
'labels' => $labels, | |
'show_ui' => true, | |
'show_admin_column' => true, | |
'query_var' => true, | |
'rewrite' => array( 'slug' => 'genre' ), | |
); | |
register_taxonomy( 'genre', array( 'book' ), $args ); | |
} | |
add_action( 'init', 'create_book_taxonomies', 0 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment