Support » Developing with WordPress » Add custom tags support to Gutenberg editor

  • Resolved vincurekf


    I have been trying to add tags support to custom post type.
    I have enabled Gutenberg support for custom post and tried to enable post_tag in $args configuration:

    $args = array(
      'show_in_rest' => true,
      'taxonomies' => array( 'category', 'post_tag' ),
    register_post_type( 'myslug', $args );

    I have tried registering custom myslug_tag:

    $args = array(
      'show_in_rest' => true,
      'taxonomies' => array( 'category', 'myslug_tag' ),
    register_post_type( 'myslug', $args );
        'label' => __( 'Tags', 'text_domain_myslug' ),
        'singular_name' => __( 'Tag', 'text_domain_myslug' ),
        'hierarchical'  => false,
        'rewrite'       => true,
        'query_var'     => true

    But that does not work either.
    The second approach gives me the “Tags” link in custom post type menu in admin sidebar, but when I try to edit the post, tags are not there.

    The tags work when I use the classic editor, I can select or add new tags, but when I switch back to Gutenberg, tags disappear.

    Am I doing something wrong here or did custom tags changed so much with Gutenberg editor?

    Thank you

    All code runs in the init hook:

    add_action('wp_init', array( $this, 'register_types' ) );

    Where register_types is public function that:

    • 1. Calls register_post_type()
    • 2. Calls register_taxonomy()
    • This topic was modified 1 year, 6 months ago by vincurekf. Reason: additional info

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Fixed it by using working solution from plugin:

    $slug = 'myslug';
    $taxonomy_name = $slug . '-tag';
    $labels = Array(
      'name' => 'Tags',
      'singular_name' => 'Tag',
      'search_items' => 'Search Tags',
      'all_items' => 'All Tags',
      'edit_item' => 'Edit Tag',
      'update_item' => 'Update Tag',
      'add_new_item' => 'Add New Tag',
      'new_item_name' => 'New Tag'
    $args = Array(
      'label' => sprintf( '%s: Tags', $slug ),
      'labels' => $labels,
      'show_admin_column' => True,
      'hierarchical' => False,
      'show_ui' => True,
      'query_var' => True,
      'rewrite' => Array(
        'with_front' => False,
        'slug' => ltrim(sprintf('%s/tag', $slug), '/')
      'show_in_rest' => True,
    register_Taxonomy($taxonomy_name, $slug, $args);
Viewing 1 replies (of 1 total)
  • The topic ‘Add custom tags support to Gutenberg editor’ is closed to new replies.