WordPress Taxonomy: What It Is and How to Create Custom Taxonomies

WordPress taxonomy is a way of organizing content within a WordPress website. It is a hierarchical system of categorizing content, similar to a library’s Dewey Decimal System. Taxonomies are used to group related content together, making it easier for users to find what they’re looking for.

WordPress comes with two built-in taxonomies: categories and tags. Categories are used to group content into broad topics, while tags are used to further refine the content within a category. For example, a blog post about a new restaurant in town might be categorized as “Food & Drink” and tagged with “Restaurants” and “New York City.”

In addition to the built-in taxonomies, WordPress also allows users to create custom taxonomies. Custom taxonomies are used to further refine content and make it easier to find. For example, a website about cars might have a custom taxonomy for “Car Make” and “Car Model.” This would allow users to quickly find content related to a specific make and model of car.

Creating custom taxonomies in WordPress is relatively easy. All you need to do is go to the “Taxonomies” section of the WordPress admin panel and click “Add New.” From there, you can enter the name of the taxonomy, a description, and the types of content it should be associated with. Once you’ve saved the taxonomy, you can start assigning it to posts and pages.

WordPress taxonomy is a powerful tool for organizing content and making it easier to find. With the built-in taxonomies and the ability to create custom taxonomies, WordPress users have a lot of flexibility when it comes to organizing their content.
[ad_1]

WordPress Taxonomy: What It Is and How to Create Custom Taxonomies

WordPress Codex defines taxonomy as a grouping mechanism for all of your content. In short, it allows you to group your posts based on shared characteristics.

Let’s say that you have a website about movies. Chances are you want to group the movies based on genre. Taxonomies allow you to do just that, thus helping users to navigate your site.

Although the term “Taxonomy” does come from biology, in this article we will explain what is WordPress Taxonomy, what are Custom Taxonomies and how to create them.

Simply speaking, in WordPress, a taxonomy is a mechanism used to group content together. The two most used WordPress taxonomy types are Categories and Tags which allows you to make your website easy for the users to navigate.

Types of WordPress Taxonomies

In total, there are four taxonomies in WordPress that you can use to group your posts. Let’s take a look at each one.

1. Category

The category taxonomy in WordPress lets you group your post into hierarchical categories. There are two different ways to group your posts via Categories.

The first way is to log in to your Dashboard and head to Posts -> Categories. There, you can define your categories, as well as add in the WordPress slug and define child categories.  

adding categories from posts menu
Adding categories and setting the parent-child relation.

The second option is to head to Posts -> Add New. You can add multiple categories directly from the panel next to your visual editor. While it is the easier option, it doesn’t let you define the slug and description.

adding categories from the visual editor

2. Tag

Tags are similar to categories – it groups your posts. However, it doesn’t have a hierarchical structure.

A tag is a single parameter that puts your similar posts together, but it focuses on smaller details of your content, rather than overall themes.

Let’s say that you want to create genres and subgenres for your movie WordPress site. You can do that by using category like taxonomy, as it supports hierarchical structure. If you want to group movies of any genre with Brad Pitt as the main star, you can add tags.

Creating WordPress tags is similar to creating categories. You can do it either from Posts -> Tags or panel next to the visual editor. Slug and description can also be defined.

adding tags from the visual editor
Adding tags from the visual editor

Pro Tip

While tags are optional, categories are mandatory for your posts. Every post needs at least one category. By default, WordPress will automatically put your post under “Uncategorized” category.

The other 2 taxonomies are not visible to visitors. Although rarely used, they are still worth mentioning.

This taxonomy lets you categorize your links. If you link to many sources on your posts, you’ll find this feature particularly useful.

4. Post_format

Post_format enables you to categorize your posts based on the types – videos, standard, audio, and more. You can find the panel next to your visual editor.

format taxonomy

Custom WordPress Taxonomies

At the right side of your visual editor, you can see the “Categories” and “Tags” label. What if you want to have your own taxonomy that says “People”? Here’s where custom taxonomy saves the day. You can customize your taxonomy to better accommodate your needs.

Customized people taxonomy

For example, think of a fitness WordPress site. Instead of having a general taxonomy that says “categories”, it would be better to have custom taxonomies that say “Cardio” and “Floor Exercises”. Each taxonomy can be further modified with sub-categories like “Jogging”, “Intermittent running”, and “Crunches”. The same case goes with tags. You can have a tag that says “Fitness Instructor” instead of the default names.

How to Create Custom Taxonomies in WordPress

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

Using Plugins

Plugins make everything easy and creating a custom taxonomy is no exception. You don’t need any technical knowledge to do it.

The recommended plugins for creating custom taxonomies are Custom Post Types UI and Pods. Let’s try using the former for the example.

  1. Install and activate Custom Post Types UI
  2. Head to CPT UI -> Add/Edit Taxonomies
  3. Complete the box with your taxonomy name. In our case, we use “Floor Exercise”. Also, choose the custom post types on which you want to apply the new taxonomy.creating custom taxonomies with CTP UI
  4. Hit Add Taxonomy button at the bottom.
  5. If you head to Posts -> Add New, the new taxonomy will appear next to the visual editor.floor exercise new taxonomy on visual editor

You may notice that the new taxonomy is a tag called “Floor Exercise”. What if you want to create a category instead? Easy! Scroll down a bit and change Hierarchical to True.

changing tags to categories in CTP UI

The result will look like this:

floor exercise custom categories

You can also use the plugin to create Custom Post Types.

Adding Code to functions.php

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

For advanced users, you only need to add a few lines of the functions.php file of your theme’s directory. Please be aware that the codes for the hierarchical taxonomy are different from the non-hierarchical one.

Take a look at the example below.

Hierarchical taxonomy (category):

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

//create a custom taxonomy name it topics for your posts
function 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_book_taxonomies when it fires
add_action( 'init', 'create_topics_hierarchical_taxonomy', 0 );

//create a custom taxonomy name it topics for your posts
function 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 show 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 correctly, a new taxonomy called “Topic” will appear on your visual editor.

Conclusion

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

Correctly utilizing WordPress taxonomies will help boost your website’s user experience.

[ad_2]

WordPress Taxonomy: What It Is and How to Create Custom Taxonomies

WordPress taxonomy is a way to organize content on your website. It is a hierarchical system of categorizing content, similar to how you would organize a library. Taxonomies are used to group related content together, making it easier for visitors to find what they are looking for. Taxonomies can be used to organize posts, pages, custom post types, and even media.

What Is a Taxonomy?

A taxonomy is a way of organizing content into categories and subcategories. It is a hierarchical system, meaning that each category can have multiple subcategories, and each subcategory can have multiple sub-subcategories. This allows you to create a structure for your content that makes it easier for visitors to find what they are looking for.

WordPress comes with two built-in taxonomies: categories and tags. Categories are used to group related posts together, while tags are used to describe individual posts. You can also create custom taxonomies to further organize your content.

How to Create Custom Taxonomies

Creating custom taxonomies in WordPress is easy. All you need to do is use the register_taxonomy() function. This function takes several parameters, including the name of the taxonomy, the labels for the taxonomy, and the arguments for the taxonomy. Once you have registered the taxonomy, you can then assign it to posts, pages, or custom post types.

You can also create custom taxonomy terms. This is done using the register_taxonomy_term() function. This function takes several parameters, including the name of the taxonomy, the labels for the taxonomy term, and the arguments for the taxonomy term. Once you have registered the taxonomy term, you can then assign it to posts, pages, or custom post types.

Conclusion

WordPress taxonomy is a powerful tool for organizing content on your website. It is a hierarchical system of categorizing content, making it easier for visitors to find what they are looking for. WordPress comes with two built-in taxonomies: categories and tags. You can also create custom taxonomies and taxonomy terms to further organize your content.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00