Registering custom taxonomies

Taxonomy allows for classifying your posts in groups.

They should be registered inside app/Structure/taxonomies.php file within init action. Starter registers book_genre taxonomy as an example. Customize it to your needs.

namespace Tonik\Theme\App\Structure;

function register_book_genre_taxonomy()
{
  register_taxonomy('book_genre', 'book', [
    'rewrite' => [
      'slug' => 'books/genre',
      'with_front' => true,
      'hierarchical' => true,
    ],
    'hierarchical' => true,
    'public' => true,
  ]);
}
add_action('init', 'Tonik\Theme\App\Structure\register_book_genre_taxonomy');
Spotted a mistake or want to contribute to the documentation? Edit this document on Github!