Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom taxonomy terms not showing as list in post edit view #12826

Closed
florianbrinkmann opened this issue Dec 12, 2018 · 4 comments
Closed

Custom taxonomy terms not showing as list in post edit view #12826

florianbrinkmann opened this issue Dec 12, 2018 · 4 comments
Labels
[Feature] Document Settings Document settings experience [Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@florianbrinkmann
Copy link

Maybe it is the wanted behavior, but: I have created a Custom Taxonomy for a Custom Post Type. When editing a post of this CPT, I see the meta box of the Custom Taxonomy with a field to add new or select existing terms. But there is no list of all existing terms, like it is the case for the normal blog categories.

This is what I get:

custom-taxonomy-question

While searching if that is the right behavior, I saw a screenshot from WooCommerce in another issue (#3369 (comment)) where such a list is present, so I’m wondering – how can I get such a list of all existing terms for my Custom Taxonomy? :)

This is the code for registering the Custom Taxonomy:

$product_cats_args = array(
	'labels'                     => $product_cats_labels,
	'hierarchical'               => false,
	'public'                     => true,
	'show_ui'                    => true,
	'show_admin_column'          => true,
	'show_in_nav_menus'          => false,
	'show_in_rest'               => true,
	'show_tagcloud'              => false,
);
register_taxonomy( 'product_cats', array( 'collection' ), $product_cats_args );

Thanks in advance!

@florianbrinkmann florianbrinkmann changed the title Custom taxonomies not showing as list in post edit view Custom taxonomy terms not showing as list in post edit view Dec 12, 2018
@swissspidy swissspidy added [Feature] Document Settings Document settings experience [Type] Help Request Help with setup, implementation, or "How do I?" questions. labels Dec 13, 2018
@swissspidy
Copy link
Member

Isn't this just a difference between hierarchical and non-hierarchical taxonomies?

Just like in the Classic Editor, hierarchical taxonomies like categories get checkboxes, flat taxonomies like post tags get a free-form text field.

@florianbrinkmann
Copy link
Author

Thanks a lot @swissspidy, that was the problem, changing hierarchical to true fixes it :)

@umeshtechahead
Copy link

$product_cats_args = array(
'labels' => $product_cats_labels,
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => false,
'show_in_rest' => true,
'show_tagcloud' => false,
);
register_taxonomy( 'product_cats', array( 'collection' ), $product_cats_args );

@juanRabaa
Copy link

$product_cats_args = array(
'labels' => $product_cats_labels,
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => false,
'show_in_rest' => true,
'show_tagcloud' => false,
);
register_taxonomy( 'product_cats', array( 'collection' ), $product_cats_args );

The show_in_rest' => true does the trick here. It seems like, for some reason, wordpress fetches the posts taxonomies via a REST request instead of rendering them with php. If show_in_rest is set to false, the REST callback ignores that taxonomy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Document Settings Document settings experience [Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

4 participants