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

Gutenberg doesn't show metaboxes for Tags & Categories, for custom post types #19388

Closed
nicolasleroy opened this issue Jan 2, 2020 · 6 comments
Labels
[Status] Needs More Info Follow-up required in order to be actionable.

Comments

@nicolasleroy
Copy link

nicolasleroy commented Jan 2, 2020

When enabling a custom post type for default taxonomies "category" and "post_tag", Gutenberg doesn't show the Tags & Categories metaboxes in the right-hand panel.

Steps to reproduce the behavior:

  1. I have installed a fresh WordPress setup; using TwentyNineteen as theme.

  2. In functions.php, I have created my post type using the following piece of code:

register_post_type('album', array(
			'public' => true,
			'show_ui' => true,
			'publicly_queryable' => true,
			'exclude_from_search' => false,
			'map_meta_cap' => true,
			'capability_type' => 'post',
			'hierarchical' => false,
			'query_var' => true,
			'supports' => array('title', 'editor', 'custom-fields', 'comments'),		
			'label' => __('Albums'),
			'singular_label' => __('Album'),
			'show_in_rest' => true,
			'taxonomies' => array('category', 'post_tag'),
			'rewrite' => array('slug' => 'album', 'with_front' => false )
		));
  1. In WordPress Admin, I can create a new “album” without any problem, but don’t see the metabox to create tags (as I do see when creating a post)

  2. On the page to create a new “album”, when checking “3 dots > Options”, I don’t see the option to display the “Tags” metabox.

  3. When debugging, and doing “print_r($wp_taxonomies);”, I can see that my custom post type “album” is registered within the “[object_type]” array of “[post_tag] => WP_Taxonomy Object”

  4. Issue reproduced on 3 different instances of Wordpress.

Expected behavior : I expect a metabox to manage Tags & Categories, to appear on the right-hand side, as I do have when managing posts.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Microsoft Edge with Chromium
  • Version: 80.0.361.9
  • Wordpress 5.3.2, with embedded Gutenberg version.

PS: a support request has been created, but I have been advised to open a bug request instead - https://wordpress.org/support/topic/custom-post-types-gutenberg-tags-2-2/

@youknowriad
Copy link
Contributor

I was not able to reproduce this personally as you can see in the screenshot (album CPT created with the exact same code as above)

Capture d’écran 2020-01-13 à 2 28 44 PM

@youknowriad youknowriad added the [Status] Needs More Info Follow-up required in order to be actionable. label Jan 13, 2020
@nicolasleroy
Copy link
Author

Interesting. @youknowriad would you be able to tell me what Wordpress / Gutenberg versions you use? Thanks !

@youknowriad
Copy link
Contributor

I'm using master (this is Gutenberg 7.2 approximatively) but I'm pretty sure we didn't touch this code for a long time now.

@nicolasleroy
Copy link
Author

Thanks @youknowriad .

I have reinstalled a fresh Wordpress 5.3.2, with TwentyNineteen as theme. I have added Gutenberg 7.3 as plugin. I have added the CPT definition in functions.php (I've tried at the top of it, at the bottom of it).

And still don't see Tags or Categories metaboxes in the right-hand side column.

Really don't get what can be different between my setup and yours ... What mystery.

image

@youknowriad
Copy link
Contributor

I think the issue is that you should run the CPT creation on the "init" hook and not at the root of the file. this should fix it.

@nicolasleroy
Copy link
Author

@youknowriad THANK YOU SO MUCH !!! I had this problem opened for 8 months, was unable to put my head around this... And it was a matter of reading properly the documentation for register_post_type ...

Thank you very much again, as I wouldn't have solved this by myself.

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

No branches or pull requests

2 participants