August 2017
Beginner
412 pages
10h 30m
English
Just to follow the example given a while ago with our custom post type for books, let's now create a custom taxonomy. Essentially, you might not want to mix book categories and post categories, so we are going to create a custom taxonomy named Book Categories. Add the following code to your functions.php file:
function build_taxonomies() {
register_taxonomy(
'book_category',
'book',
array(
'hierarchical' => true,
'label' => 'Book Category',
'query_var' => true,
'rewrite' => array('slug' => 'available-books')
)
);
}
add_action('init', 'build_taxonomies', 0);
Like the register_post_type() function, the register_taxonomy() function allows you to register a new taxonomy within WordPress. You can read up ...
Read now
Unlock full access