Registering a Custom Taxonomy

Last updated Apr 21, 2023

Overview

Taxonomies are used to classify and categorize individual posts for a post type. WordPress provides an admin UI for managing terms in a taxonomy and categorizing posts with terms.

List of taxonomies created with ACF.

Add New

To register a new taxonomy, navigate to the ‘ACF’ > ‘Taxonomy’ screen and click ‘Add New’. You will see a screen with some basic settings for the taxonomy.

Adding a new taxonomy with ACF.

Basic Settings

The required fields of “Plural Label”, “Singular Label” and “Taxonomy Key” are the minimum required information to create a taxonomy, however, there are other settings available if you want to perform more granular configurations.

Plural Label

This is the plural label of the taxonomy you are registering. For example, Genres, Series, Franchises.

Singular Label

This is the singular label of the taxonomy you are registering. For example, Genre, Series, Franchise.

Taxonomy Key

This is automatically generated from the singular label you enter but can be changed. It must be a string made up of lowercase letters, numbers, underscores and dashes only. It has a 20 character limit.

Post Types

Select one or more existing post types to connect the taxonomy to, so that objects of the post types can be classified with the taxonomy

Public

This setting controls if the taxonomy is public or private. It is on by default, meaning the taxonomy shows in the admin dashboard and is publicly accessible on the site frontend.

Hierarchical

This setting controls the type of taxonomy when it comes to allowing parent and child relationships between taxonomy terms. The native WordPress Category taxonomy is hierarchical but Tags is not. It is off by default.

Advanced Configuration

There are a large number of settings that can be configured when registering a taxonomy. To keep things simple, ACF doesn’t show them by default but you can control them when the ‘Advanced Configuration’ toggle is on.

Advanced Settings when creating a taxonomy with ACF.

General

The ‘General Settings’ gives you several general settings related to the taxonomy.

Sort Terms

Whether terms in this taxonomy should be sorted in the order they are provided to wp_set_object_terms().

Default Term

Create a term for the taxonomy that cannot be deleted. It will not be selected for posts by default.

Term Name

The name of the default term (required).

Term Slug

Single word, no spaces. Underscores and dashes allowed.

Term Description

A descriptive summary of the term.

Description

A descriptive summary of the taxonomy.

Active

The active toggle is a quick way to deactivate the taxonomy so it can be turned off without deleting it.

Labels

The ‘Labels’ tab allows you to define the label strings used for the taxonomy throughout the admin dashboard. You can quickly either regenerate all labels based on your ‘Plural Label’ and ‘Singular Label’ entered earlier or clear all labels.

All of the labels used by WordPress can be configured.

Visibility

The ‘Visibility’ tab contains the settings that control how the taxonomy will be displayed in the admin dashboard and the frontend of the site. Control how it appears in the sidebar menu, remove it from the admin bar, exclude it from search results on the frontend, and more.

Show in UI

Enabled by default, this means the taxonomy can be edited and managed in the WordPress admin dashboard.

Show in Admin Menu

Enabled by default, this controls if the taxonomy appears in the sidebar menu in the admin dashboard.

Meta Box

Controls the meta box on the content editor screen. By default, the Categories meta box is shown for hierarchical taxonomies, and the Tags meta box is shown for non-hierarchical taxonomies. Allows you to supply a custom meta box callback or disable the meta box completely.

Register Meta Box Callback

A PHP function name to be called to handle the content of a meta box on your taxonomy.

Meta Box Sanitization Callback

A PHP function name to be called tor sanitizing taxonomy data saved from a meta box.

Appearance Menus Support

Enabled by default, controls if items can be added to menus in the ‘Appearance’ > ‘Menus’ screen. Must be turned on in ‘Screen options’.

Tag Cloud

Enabled by default, list the taxonomy in the Tag Cloud Widget controls.

Quick Edit

Enabled by default, show the taxonomy in the quick/bulk edit panel.

Show Admin Column

Display a column for the taxonomy on post type listing screens.

URLs

The ‘URLs’ tab contains the settings that control how the taxonomy appears in URLs. This includes the permalink structure of URLs for terms of the taxonomy, and how to control the query variable settings for the URL.

Permalink Rewrite

Rewrite the URL for an item of the taxonomy using the taxonomy key as the slug, a custom slug or disable it to prevent URL rewriting.

Front URL Prefix

Enabled by default, alters the permalink structure to add the WP_Rewrite::$front prefix to URLs.

Hierarchical

Enables parent-child terms in URLs for hierarchical taxonomies.

Publicly Queryable

Enabled by default, controls if URLs for an item and items can be accessed with a query string.

Query Variable Support

Controls id items can be accessed using the non-pretty permalink, with the taxonomy key as the query variable, a custom variable or query variable access is disabled.

REST API

The ‘REST API’ tab contains settings to control the taxonomy’s behavior in the WordPress REST API.

Show in REST API

Enabled by default, controls if this taxonomy is exposed in the REST API.

Base URL

The base URL for the taxonomy REST API URLs.

Namespace Route

The namespace part of the REST API URL.

Controller Class

Optional custom controller to use instead of WP_REST_Terms_Controller.

The Next Step

Once you have configured the taxonomy and saved your changes, a saved success notice appears along with some helpful links to perform typical next actions.

The next steps after saving a taxonomy with ACF.

These include:

Creating a New Field Group

A common workflow is to register a taxonomy then add some fields to it to store other structured data outside of the term title and content. This is made extremely easy by clicking the ‘Add fields to’ link, which takes you to a new field group where the location rule is already set to make the field group appear when editing terms of the new taxonomy.

Connecting to Existing Field Groups

There will be times when a new taxonomy is created and existing field groups should also be displayed when editing terms of the new taxonomy. You can connect existing field groups by clicking the ‘Link existing field groups’ link and selecting the field groups in the modal that appears.

This process adds a new location rule to the selected field groups to make them appear when editing terms of the new taxonomy.