Visit Eventchamp WordPress theme to create a new events & conference website. Eventchamp WordPress Events Theme

How to Create Custom Taxonomies in WordPress

Table of Contents

Taxonomies are an essential part of WordPress, allowing users to organize and classify their content. By default, WordPress comes with two taxonomies: categories and tags. These taxonomies help users organize their posts into different groups, making it easier for visitors to find and browse related content on their website.

In this article, we will explain what taxonomies are and how they work in WordPress. We will also provide a detailed guide on how to create and manage custom taxonomies in WordPress, both with and without using a plugin.

What are Taxonomies?

In simple terms, a taxonomy is a way of organizing and categorizing content. It provides a systematic approach to classify and group similar items together. This helps users to easily find and access the information they are looking for.

Hire Us

Taxonomies can be applied to various types of content, such as blog posts, products, events, or any other type of information that can be organized into categories and subcategories.

In WordPress, taxonomies are used to organize and classify posts, pages, and other custom post types. By default, WordPress comes with two taxonomies: categories and tags.

Categories vs Tags

Categories and tags are the two default taxonomies in WordPress. They are both used to organize and classify posts, but they serve different purposes.

Categories are used to group posts into broad topics or sections. For example, a blog about pets may have categories for dog breeds, cat breeds, and pet care. Categories help users to browse and discover related content on a website.

Tags, on the other hand, are used to add specific details and labels to posts. They provide a more granular level of classification and allow users to search for specific topics or keywords. For example, a post about a dog breed may have tags for its size, color, and temperament.

Categories and tags work together to provide a comprehensive and organized system for classifying posts in WordPress.

How to Create Custom Taxonomies in WordPress

While categories and tags are useful for organizing posts, they may not be enough for some websites. In some cases, users may want to create their own custom taxonomies to classify their content in a more specific or unique way.

Custom taxonomies can be created in WordPress using a plugin or by modifying the theme’s functions.php file. Let’s take a look at both methods.

Creating a Taxonomy Using a Plugin

Creating custom taxonomies in WordPress can be easily done using a plugin. There are many plugins available that provide an user-friendly interface for creating and managing custom taxonomies on a WordPress website.

One popular plugin for custom taxonomy creation is Custom Post Type UI. This plugin offers a straightforward interface for creating and managing custom taxonomies in WordPress.

To create a custom taxonomy using the Custom Post Type UI plugin, follow these steps:

  1. Install and activate the Custom Post Type UI plugin.
  2. Go to CPT UI > Add/Edit Taxonomies.
  3. Enter a name for the taxonomy in the Singular Label field. This will be the name displayed on the website for the taxonomy.
  4. Enter the plural version of the name in the Plural Label field. This will be the name displayed when multiple items of the taxonomy are displayed.
  5. Enter a unique slug for the taxonomy in the Slug field. This is the part of the URL that will identify the taxonomy.
  6. Set the other options for the taxonomy as needed, such as whether it is hierarchical, public, etc.
  7. Click on the Add New Taxonomy button to create the custom taxonomy.

After creating the custom taxonomy, it will be available for use on the website. Users can then manage and assign terms to the taxonomy in the same way as the default categories and tags.

Creating a Taxonomy Without Using a Plugin

While using a plugin is the easiest way to create custom taxonomies in WordPress, users who are comfortable with code can create custom taxonomies without using a plugin. This method involves modifying the theme’s functions.php file to register the custom taxonomy.

Hire Us

Here is an example of how to create a custom taxonomy using code:

function create_custom_taxonomy() {
  $labels = array(
    'name' => 'Locations',
    'singular_name' => 'Location',
    'menu_name' => 'Locations',
    'all_items' => 'All Locations',
    'parent_item' => 'Parent Location',
    'parent_item_colon' => 'Parent Location:',
    'new_item_name' => 'New Location Name',
    'add_new_item' => 'Add New Location',
    'edit_item' => 'Edit Location',
    'update_item' => 'Update Location',
    'view_item' => 'View Location',
    'separate_items_with_commas' => 'Separate locations with commas',
    'add_or_remove_items' => 'Add or remove locations',
    'choose_from_most_used' => 'Choose from the most used',
    'popular_items' => 'Popular Locations',
    'search_items' => 'Search Locations',
    'not_found' => 'Not Found',
    'no_terms' => 'No locations',
    'items_list' => 'Locations list',
    'items_list_navigation' => 'Locations list navigation',
  );
  $args = array(
    'labels' => $labels,
    'hierarchical' => true,
    'public' => true,
    'show_ui' => true,
    'show_admin_column' => true,
    'show_in_nav_menus' => true,
    'show_tagcloud' => true,
  );
  register_taxonomy('locations', array('post'), $args);
}
add_action('init', 'create_custom_taxonomy', 0);

This code registers a new custom taxonomy called “Locations” for the “post” post type. The code defines the labels for the taxonomy and sets the arguments for how the taxonomy will work.

To use this code on your website, follow these steps:

  1. Go to Appearance > Theme Editor.
  2. Click on the functions.php file on the right-hand side.
  3. Paste the code at the bottom of the file and save the changes.
function.php file on WordPress

After adding the code, the custom taxonomy will be registered and available for use on the website.

Managing Custom Taxonomies in WordPress

Once custom taxonomies have been created, they can be easily managed and used on a WordPress website. The process for managing custom taxonomies is similar to the default categories and tags.

To manage custom taxonomies, follow these steps:

  1. Go to Posts > Categories (or Tags) in the WordPress admin dashboard.
  2. Click on the custom taxonomy you want to manage.
  3. From here, you can add, edit, and delete terms in the taxonomy.

Custom taxonomies can also be added to the post editor screen, allowing users to easily assign terms to posts. To do this, follow these steps:

  1. Go to Posts > All Posts in the WordPress admin dashboard.
  2. Click on the post you want to edit.
  3. Scroll down to the post editor screen and click on the Screen Options button at the top right.
  4. In the Screen Options panel, check the box next to the custom taxonomy you want to display on the post editor screen.
  5. The custom taxonomy will now be available in the post editor screen, allowing users to easily assign terms to the post.

Managing custom taxonomies in WordPress is easy and allows users to provide a more comprehensive and organized system for their content.

Conclusion

In this article, we have explained what taxonomies are and how they work in WordPress. We have also provided a detailed guide on how to create and manage custom taxonomies in WordPress, both with and without using a plugin.

Custom taxonomies can be a useful tool for organizing and classifying content on a WordPress website. By creating custom taxonomies, users can provide a more comprehensive and organized system for their content, making it easier for visitors to find and access the information they are looking for.

Using a plugin is the easiest way to create custom taxonomies in WordPress. However, users who are comfortable with code can create custom taxonomies without using a plugin by modifying the theme’s functions.php file.

Regardless of the method used, custom taxonomies can provide a powerful and flexible way to organize and classify content on a WordPress website.

Picture of Katerina Valeria
Katerina Valeria
Hi there! My name is Catherine and I am a professional content creator with a focus on WordPress. I write blog articles for Gloria Themes, sharing my knowledge and expertise on all things related to this popular website platform.

Subscribe to Our Newsletter for Updates, Tips, and Offers

Facebook
Twitter
LinkedIn
Pinterest
WhatsApp

Hand-Picked Related Articles

If you’re looking for helpful tips and tricks on improve your WordPress website or improving your web design skills, be sure to check out our related articles for valuable insights and resources.

Spam Comments

Discover effective strategies to stop WordPress spam comments, safeguard your site, and enhance user experience with our comprehensive guide.