Custom taxonomies

Wpsnipp – Taxonomy is one of those words that most people never hear or use. Basically, a taxonomy is a way to group things together. Adding this PHP code to your functions.php of your wordpress theme will allow you to create custom taxonomies. By default wordpress has category, tag in this sample we have genre, actors.

 

 

 

add_action( 'init', 'create_my_taxonomies', 0 );
function create_my_taxonomies() {
register_taxonomy( 'genre', 'post', array( 'hierarchical' => false, 'label' => 'Genre', 'query_var' => true, 'rewrite' => true ) );
register_taxonomy( 'actors', 'post', array( 'hierarchical' => false, 'label' => 'Actors', 'query_var' => true, 'rewrite' => true ) );
}

Leave a comment