There are two different paths of creating Custom Taxonomies in WordPress. You can do it with coding, or you can do it thought plugins.

Using Plugin to create Custom Taxonomies

Plugins make work everything simple and making a custom taxonomy is no exception. You don’t requirement any technical knowledge to do it.

The suggested plugins for making custom taxonomies are Custom Post Types UI and Pods. Let’s try using the first one for an example.

  • Install and activate Custom Post Type UI.
  • Now head to CPT UI ->Add/Edit Taxonomies.
  • Brimful the box with your taxonomy name. In our affair, we use “cloud”. Forby, choose the custom post types on that you want to wage the new taxonomy.
  • Press Add Taxonomy button at the bottom.
  • If you go to Posts -> Add New, so the new taxonomy will see next to the visual editor.

You may see that the new taxonomy is a tag called “Cloud”. What if you wish creating a category instead? Easy! Scroll down a little and alter Hierarchical to True.

The result will see like this:

You can also for use the plugin to make Custom Post Types.

Adding Code to functions.php

You should select this method only then you are comfortable with coding. if not, ignore tutorial and to using plugins only.

For improved users, you some requirement to add a few lines of the functions.php file of your theme’s directory. Please be attention the codes for the hierarchical taxonomy are varianted from the non-hierarchical one.

Take a look at the example below.

Hierarchical Taxonomy (Category):

//hook into the init action and call create_cloud_taxonomies when it fires
add_action( 'init', 'webart_create_topics_hierarchical_taxonomy', 0 );

//create a custom taxonomy name it topics for your posts
function webart_create_topics_hierarchical_taxonomy() {

// Add new taxonomy, make it hierarchical like categories

//first do the translations part for GUI
 $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_item_colon' =__( 'Parent Topic:' ),
   'edit_item' =__( 'Edit Topic' ),
   'update_item' =__( 'Update Topic' ),
   'add_new_item' =__( 'Add New Topic' ),
   'new_item_name' =__( 'New Topic Name' ),
   'menu_name' =__( 'Topics' ),
 );  

// Now register the taxonomy
 register_taxonomy('topics',array('post'), array(
   'hierarchical' =true,
   'labels' =$labels,
   'show_ui' =true,
   'show_admin_column' =true,
   'query_var' =true,
   'rewrite' =array( 'slug' = 'topic' ),
 ));
}

Non-Hierarchical Taxonomy (tag):

//hook into the init action and call create_cloud_taxonomies when it fires
add_action( 'init', 'webart_create_topics_hierarchical_taxonomy', 0 );

//create a custom taxonomy name it topics for your posts
function webart_create_topics_hierarchical_taxonomy() {

// Add new taxonomy, make it hierarchical like categories

//first do the translations part for GUI
 $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_item_colon' =__( 'Parent Topic:' ),
   'edit_item' =__( 'Edit Topic' ),
   'update_item' =__( 'Update Topic' ),
   'add_new_item' =__( 'Add New Topic' ),
   'new_item_name' =__( 'New Topic Name' ),
   'menu_name' =__( 'Topics' ),
 );  

// Now register the taxonomy
 register_taxonomy('topics',array('post'), array(
   'hierarchical' =true,
   'labels' =$labels,
   'show_ui' =true,
   'show_admin_column' =true,
   'query_var' =true,
   'rewrite' =array( 'slug' = 'topic' ),
 ));
}

To look the new taxonomy in your visual editor, open single.php from Editor and copy this code:

the_terms( $post-ID, 'topics', 'Topics: ', ', ', ' ' );

That’s it! If the process is done perfectly, a new taxonomy called “Topic” will look on your visual editor.

Conclusion:

WordPress Taxonomy is used grouping your content. You can use categories for topics, and tags for details in your text. You can create custom taxonomies using plugins or functions.php file.

Correctly use WordPress taxonomies will help increase your website’s user experience.

Similar Posts