I’ve been trying to setup a custom hierarchical taxonomy however when I’m editing my post using Gutenberg editor, on the right side menu the child taxonomies don’t appear and I also cannot add any new ones from there. Note that the custom slug that I selected does show up, it’s just not functional.
The obvious workaround is to add new taxonomies directly from the admin menu, but then again the problem remains since they won’t show up at all when editing the blog post. Do note, if I disable Gutenberg and use the classic editor, the taxonomies work exactly as expected.
I’ve read a few posts already about how displaying the custom taxonomies is an issue, but I’ve already handled that. My issue is specifically about selecting/adding/deleting new child taxonomies while working on a post.
Also note, this applies to default post and pages, as well as custom post types (which I’ve made sure to specifically target this taxonomy both at the register_taxonomy() and/or at the register_post_type() functions).
One last thing, "hierarchical" => false
seems to work in the sense that I’m able to add new tags. However these are not saved; when I save, leave and reopen that blog post in the admin dashboard the tags are all gone.
This is the code I wrote:
function my_custom_taxonomies(){
$labels = array(
'name' => 'Sections',
'singular_name' => 'Section',
'search_items' => 'All Sections',
'all_items' => 'All Sections',
'parent_item' => 'Parent Section',
'parent_item_colon' => 'Parent Section:',
'edit_item' => 'Edit Section',
'update_item' => 'Update Section',
'add_new_item' => 'Add New Section',
'new_item_name' => 'New Section Name',
'menu_name' => 'Sections'
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_rest' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'section')
);
register_taxonomy('sections', array('post', 'page'), $args);
}
add_action('init', 'my_custom_taxonomies');
Thank you all in advance for your help, I feel quite lost here since there doesnt seem to be any issues about this?
]]>1. Can a user have custom hierarchical taxonomies?
]]>Consequently the plugin doesn’t work. The problem affects the versions 2.1.1 and 2.1.0 as well. So I had to fallback to the 2.0.1 to have it working again.
PS: please note, also, in the error message, “hierarchical” has been typed wrong.
https://www.ads-software.com/extend/plugins/post-expirator/
]]>https://www.ads-software.com/extend/plugins/csv-importer/
]]>Can someone please help? Thanks so much!
]]>I have a Custom Post Type and a Hierarchical Taxonomy.
[CSS moderated as per the Forum Rules. Please just post a link to your site.]
With a post_type_link filter I can achieve the following URL structures:
mysite.com/eskuvoi-ruhaszalon/category1/product-name1
mysite.com/eskuvoi-ruhaszalon/category1/subcategory1/product-name1
function filter_post_type_link($link, $post) {
if ($post->post_type != 'wedding_salon') return $link;
if ($cats = get_the_terms($post->ID, 'salon_location')) $link = str_replace('%salon_location%', array_pop($cats)->slug, $link);
return $link;
}
add_filter('post_type_link', 'filter_post_type_link', 10, 2);
But taxonomy subcategory pages return with 404 error. I can only access subcategories without hierarchical structure.
mysite.com/eskuvoi-ruhaszalon/category1/subcategory1 – doesn’t work 404
mysite.com/eskuvoi-ruhaszalon/subcategory1 – it works
Do you have any idea how can I fix hierarchical taxonomy URL structure in this case?
]]>