Creating a Custom Taxonomy with ACF

Last updated Nov 13, 2024

Overview

Taxonomies in WordPress allow for the classification and organization of structured data. WordPress comes with the “Posts” post type, which already has two default taxonomies: Categories and Tags.

  • Categories allow for hierarchical organization with parent-child relationships.
  • Tags are non-hierarchical and do not have parent-child relationships.

But what if you need a custom taxonomy unique to your data structure? In this video, we show how to use ACF to register and associate custom taxonomies with a custom post type. Following this tutorial, you’ll extend the “Car” post type we registered in Creating a Custom Post Type with ACF and assign two new taxonomies: “Manufacturer” and “Make.” You’ll also see how to create manufacturers and output all the information in our Twenty Nineteen child theme.

Step 1: Registering Custom Taxonomies

The step-by-step instructions below illustrate how to create two custom taxonomies and then use them in the “Car” custom post type we created in our previous video.

First, we’ll use ACF to create a custom taxonomy for “Manufacturers.” In the WordPress admin, navigate to ACF > Taxonomies and click Add New.

Start by creating the “Manufacturers” taxonomy. Enter the following into the required fields:

  • Plural Label: Manufacturers
  • Singular Label: Manufacturer
  • Taxonomy Key: manufacturer
  • Post Types: Car

You can enter multiple “Post Types” if you’d like the custom taxonomy to be available for more than one.

Check the Hierarchical toggle to ensure the taxonomy allows for nested parent-child relationships. This will allow content editors to enter the manufacturer with the specific vehicle brand nested within it, such as “Kia – Seltos” or “Ford – Focus”.

Toggling on “Advanced Configuration” will show many more options you can use for your custom taxonomy. These options are covered in our documentation on Registering a Custom Taxonomy.

The custom taxonomy editing screen in ACF, showing the options described in the text of the article.

Click Save Changes to save your custom taxonomy.

The next step is create the “Make” taxonomy. Repeat the process outlined above, but use the following information for our required fields:

  • Plural Label: Makes
  • Singular Label: Make
  • Taxonomy Key: make
  • Post Type: Car

We want our editors to assign freeform tags for this taxonomy, so we won’t enable the “Hierarchical” toggle.

Click Save Changes to save the “Makes” custom taxonomy.

Step 2: Assigning Custom Taxonomies to Posts

Now that you’ve registered your two new custom taxonomies and assigned them to the post type, when you edit a “Car” post, you should see the additional options for your taxonomies in the sidebar. This is where you’ll assign each car’s Manufacturer and Make.

Adding custom taxonomies to a custom post type.

Next, we’ll discover how to display these taxonomies in our child theme.

Step 3: Displaying Custom Taxonomies

With custom taxonomies registered and assigned to the post type, the next step is to create custom template logic to display this new information in the child theme.

The ACF demo child theme demonstrates the necessary template files and logic for displaying your custom post type. The demo theme will automatically register the “Car” post type, the vehicle details fields group, and the “Manufacturer” and “Make” taxonomies. There is even a full XML import that allows you to replicate a fully functioning car dealership site.

Conclusion

If you’ve followed along with the tutorials, you should have a custom post type registered with custom fields and taxonomies. We hope you’re starting to see the flexibility and simplicity of using ACF to create custom data structures. Be sure to check out all of our videos and we encourage you to experiment with the final demo code.

Supercharge Your Website With Premium Features Using ACF PRO

Speed up your workflow and unlock features to better develop websites using ACF Blocks and Options Pages, with the Flexible Content, Repeater, Clone, Gallery Fields & More.

Explore Features View Pricing

PRO Features
ACF Blocks
Options Pages
PRO Fields
Repeater
Flexible Content
Gallery
Clone