By default, a custom taxonomy panel is not added to the Gutenberg editor. That means authors are not able to select terms in the editor. That’s a problem. In this quick tip, let me show you how to turn on the feature. [It’s pretty easy.]
Gutenberg uses the REST API. When you register a custom taxonomy, by default, the taxonomy is not shown in the REST API. I’ll show you in the video below.
Let’s walk through it together.
The Code
Here is a link to the Books plugin gist if you want to work along with me.
In the configuration arguments where you register the custom taxonomy, add the following configuration parameter:
'show_in_rest' => true, // Needed for tax to appear in Gutenberg editor
For example, let’s say you are registering a Genre taxonomy. The registration arguments for this custom taxonomy might be:
$labels = [
// left out for brevity.
];
// Configuration parameters for the Genre taxonomy.
$args = [
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'show_in_rest' => true, // Needed for tax to appear in Gutenberg editor.
'query_var' => true,
'rewrite' => [ 'slug' => 'genre' ],
];
register_taxonomy( 'genre', [ 'book' ], $args );
Go Deeper
Want to go deeper into custom taxonomies? Check out these resources:
- WordPress Custom Taxonomy Basics
- Developer’s Guide to Differentiating WordPress Content Taxonomies and Terms
register_taxonomy
in WordPress Codex- WordPress Built-in and Custom Taxonomies and Terms Series
Tom says
Thank you so much for this article which very clear and so helpful ! It’s worked for me.
I was stuck with this problem and I can now sleep on both my ears !
Thank you Tonya !
Alex Varela says
You were the only one with a clear answer to show this issue, I was dealing with it for hours…. thank you I was able to make it work.
Jean Carlos says
Thank you
Mike Michaelson says
Well, I already figured out the show-in-rest => true, but my hierarchical custom taxonomy meta box that shows in Gutenberg doesn’t show the checkboxes for the terms I’ve defined, but they do show in the “quick edit” screen… If I choose the “add new…” link in the meta box it will show the newly added term as a check box, however when I go back later the term i added doesn’t show (as well as any others), but the new term does show in the admin screen for the taxonomy and the checkbox is available in the “quick edit” screen. Any thoughts on where I should be looking would be helpful. I’m sure it’s a simple thing, but I can’t seem to find it. I have tried deactivating and re-activating my plug-in to no avail.
Ann Pohl says
In case this is helpful for someone else, your taxonmy name can not be set to `type` … this will cause a blank white screen.
It will break the REST API post response since the schema includes the taxonomies in the root object instead of wrapping them: https://developer.wordpress.org/rest-api/reference/posts/.
Reference: https://github.com/WordPress/gutenberg/issues/12442
Reginaldo says
Been looking for this for a long time. It helped me a lot. Thanks!
Vladimir says
Thanks! This really worked for me. I have updated WordPress recently and I noticed my taxonomies stopped showing up in the sidebar in the Gutenberg Editor. I am relieved now :))