Video Tutorial Taxonomies


By default WordPress allows you to define several taxonomies on articles: categories and tags. It is also possible to define your own taxonomies using the register_taxonomy function. This function allows you to declare a new taxonomy which can then be used in administration.

function montheme_register_sport () {
    register_taxonomy ('sport', 'post', (
        'labels' => (
            'name' => 'Sport',
            'singular_name' => 'Sport',
            'plural_name' => 'Sports',
            'search_items' => 'Search sports',
            'all_items' => 'All sports',
            'edit_item' => 'Edit sport',
            'update_item' => 'Update sport',
            'add_new_item' => 'Add a new sport',
            'new_item_name' => 'Add a new sport',
            'menu_name' => 'Sport',
        ),
        'show_in_rest' => true,
        'hierarchical' => true,
        'show_admin_column' => true,
    ));
}
add_action ('init', 'montheme_register_sport');

You can then retrieve the list of these taxonomies on your article pages. For example to create a navigation for our taxonomy:

  'sport')); ?>

You can also create a custom page for your taxonomy by creating a file taxonomy-.php.




name)?>

description)?>

'sport')); ?>

No articles