Create Custom Taxonomies In WordPress
Taxonomy is basically grouping posts together in manageable groups. The most important taxonomy options are categories and tags. If you want to organize your content you have to create custom taxonomy.
You can create a custom taxonomy using the code in functions.php
addaction( 'init', 'createcwhierarchicaltaxonomy', 0 );
//create a custom taxonomy name
function createcwhierarchicaltaxonomy() {
$labels = array(
'name' => _x( 'Topics', 'taxonomy general name' ),
'singularname' => x( 'Topic', 'taxonomy singular name' ),
'searchitems' => _( 'Search Topics' ),
'allitems' => _( 'All Topics' ),
'parentitem' => _( 'Parent Topic' ),
'parentitemcolon' => _( 'Parent Topic:' ),
'edititem' => _( 'Edit Topic' ),
'updateitem' => _( 'Update Topic' ),
'addnewitem' => _( 'Add New Topic' ),
'newitemname' => _( 'New Topic Name' ),
'menuname' => _( 'Topics' ),
);
// taxonomy register
registertaxonomy('topics',array('post'), array(
'hierarchical' => true,
'labels' => $labels,
'showui' => true,
'showadmincolumn' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'topic' ),
));
}
Reference: https://www.wpblog.com/create-custom-taxonomies-in-wordpress/