About

Custom taxonomy's are great when you want to create a list of terms for a specific post type. For example lets say we have a custom post type of books and we want a custom taxonomy to go along with that.

All we have to do is add this code:

<?
add_action( 'init', 'authors_tax_init' );

function authors_tax_init() {
    // create a author taxonomy
    register_taxonomy(
        'author_tax',
        'books',
        array(
            'label' => __('Author Names'),
            'sort' => true,
            'args' => array('orderby' => 'term_order'),
            'rewrite' => array('slug' => 'author_names')
        )
    );
}
add_action( 'init', 'genre_tax_init' );

function genre_tax_init() {
    // create a genre taxonomy
    register_taxonomy(
        'genre_tax',
        'books',
        array(
            'label' => __('Genre Types'),
            'sort' => true,
            'args' => array('orderby' => 'term_order'),
            'rewrite' => array('slug' => 'genres')
        )
    );
}
?>

This code will create 2 new taxonomy types. One called Author Names and the other for Genre Types.

All you have to do is insert this into your themes functions.php (create if it does not exisit) or make it a plugin alongside with the custom post types found here Custom Post Type Wiki

This wiki article is best used with the following wiki article as well Custom Post Types

history | show excerpt | excerpt history