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 Taxonomies Don't Show in the sidebar #3369

Closed
tomjn opened this issue Nov 7, 2017 · 7 comments
Closed

Custom Taxonomies Don't Show in the sidebar #3369

tomjn opened this issue Nov 7, 2017 · 7 comments
Labels
Core REST API Task Task for Core REST API efforts [Status] Needs More Info Follow-up required in order to be actionable.

Comments

@tomjn
Copy link
Contributor

tomjn commented Nov 7, 2017

Issue Overview

When viewing the Gutenberg editor, categories and tags appear in the sidebar, however, custom taxonomies do not

Steps to Reproduce (for bugs)

  1. Add a custom taxonomy to posts or a custom post type
    2.Open the Gutenberg editor
    3.The new taxonomies do not have a UI, and if only CT's are present, the categories and tags drawer shows nothing when expanded

Expected Behavior

I expected to see the Custom taxonomies shown the same was categories and tags are shown

Current Behavior

No custom taxonomy UI is available

Possible Solution

Show the custom taxonomies as categories and tags are shown, respecting the visibility and hierarchy attributes set on registration

@aduth
Copy link
Member

aduth commented Nov 7, 2017

Can you confirm whether the taxonomy has the show_in_rest property assigned as true? Since the editor operates using the REST API, taxonomies and post types must be whitelisted to be accessible within the editor. This is a restriction of the API itself, and one which has caused some trouble in the past.

Related: #2340, #3066

@aduth aduth added the [Status] Needs More Info Follow-up required in order to be actionable. label Nov 7, 2017
@lukecav
Copy link

lukecav commented Nov 7, 2017

You can replicate by trying WooCommerce with Gutenberg, none of the product categories using product_cat will display in Gutenberg, when say editing or creating a new product.

@lukecav
Copy link

lukecav commented Nov 7, 2017

function wc_product_category_add_tax_to_api() { $mytax = get_taxonomy( 'product_cat' ); $mytax->show_in_rest = true; } add_action( 'init', 'wc_product_category_add_tax_to_api', 30 );

Then the product categories would show.

gutenberg product categories

@tomjn
Copy link
Contributor Author

tomjn commented Nov 7, 2017

hmmm yes adding show_in_rest to my registration fixed the issue, though it's still a regression

I would expect that since anybody with editor access will have Gutenberg access then would it make sense to make it so that show_in_rest was true by default is current_user_can indicate the logged in user can modify that taxonomy? This would fix the issue without revealing terms to the public or subscribers that could cause issues

@aduth
Copy link
Member

aduth commented Nov 7, 2017

I would expect that since anybody with editor access will have Gutenberg access then would it make sense to make it so that show_in_rest was true by default is current_user_can indicate the logged in user can modify that taxonomy? This would fix the issue without revealing terms to the public or subscribers that could cause issues

This may work, and is a question more of general REST API authorization behavior than it is specific to Gutenberg. It does impact the editing experience of course, and ought to be raised for consideration. Also relevant to #3066 and previously discussed at #1342 (comment).

@mtias mtias added the Core REST API Task Task for Core REST API efforts label Nov 20, 2017
@mtias
Copy link
Member

mtias commented Nov 20, 2017

Closing as duplicate of #3066 so we can keep the conversation in a single place.

@danicotillas
Copy link

function wc_product_category_add_tax_to_api() { $mytax = get_taxonomy( 'product_cat' ); $mytax->show_in_rest = true; } add_action( 'init', 'wc_product_category_add_tax_to_api', 30 );

Then the product categories would show.

gutenberg product categories

Hi! This is working for me but I don´t know how should be the code when you have more than one Custom Category. My knowledge about PHP is not very good at all. Could you help me @lukecav ?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core REST API Task Task for Core REST API efforts [Status] Needs More Info Follow-up required in order to be actionable.
Projects
None yet
Development

No branches or pull requests

5 participants