Last Updated: December 21, 2017
·
189
· alexanderbiscajin

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' ),
'singular
name' => x( 'Topic', 'taxonomy singular name' ),
'search
items' => _( 'Search Topics' ),
'all
items' => _( 'All Topics' ),
'parent
item' => _( 'Parent Topic' ),
'parent
itemcolon' => _( 'Parent Topic:' ),
'edititem' => _( 'Edit Topic' ),
'updateitem' => _( 'Update Topic' ),
'addnewitem' => _( 'Add New Topic' ),
'new
itemname' => _( 'New Topic Name' ),
'menuname' => _( 'Topics' ),
);
// taxonomy register
registertaxonomy('topics',array('post'), array(
'hierarchical' => true,
'labels' => $labels,
'show
ui' => true,
'showadmincolumn' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'topic' ),
));
}

Reference: https://www.wpblog.com/create-custom-taxonomies-in-wordpress/