Closed canosys closed 4 years ago
Hi @canosys-
In the WordPress function that I'm using to output the terms list, wp_terms_checklist()
, https://developer.wordpress.org/reference/functions/wp_terms_checklist/
there is a line that checks whether the current user can assign terms in the taxonomy:
$args['disabled'] = ! current_user_can( $tax->cap->assign_terms );
which, if true, results in the taxonomy checkboxes being disabled.
So, however you're creating the taxonomy (I couldn't figure out how to create taxonomies via the Advanced Custom Fields plugin, but I used the CPTUI plugin successfully), you need to make sure that users who can edit docs (pretty much any logged-in user) can assign the terms in your new taxonomy. Here's a working example of a taxonomy that works for my non-admin, logged-in users:
function cptui_register_my_taxes_color() {
/**
* Taxonomy: Colors.
*/
$labels = [
"name" => __( "Colors", "twentyseventeen" ),
"singular_name" => __( "Color", "twentyseventeen" ),
"menu_name" => __( "Colors", "twentyseventeen" ),
"all_items" => __( "All Colors", "twentyseventeen" ),
"edit_item" => __( "Edit Color", "twentyseventeen" ),
"view_item" => __( "View Color", "twentyseventeen" ),
"update_item" => __( "Update Color name", "twentyseventeen" ),
"add_new_item" => __( "Add new Color", "twentyseventeen" ),
"new_item_name" => __( "New Color name", "twentyseventeen" ),
"parent_item" => __( "Parent Color", "twentyseventeen" ),
"parent_item_colon" => __( "Parent Color:", "twentyseventeen" ),
"search_items" => __( "Search Colors", "twentyseventeen" ),
"popular_items" => __( "Popular Colors", "twentyseventeen" ),
"separate_items_with_commas" => __( "Separate Colors with commas", "twentyseventeen" ),
"add_or_remove_items" => __( "Add or remove Colors", "twentyseventeen" ),
"choose_from_most_used" => __( "Choose from the most used Colors", "twentyseventeen" ),
"not_found" => __( "No Colors found", "twentyseventeen" ),
"no_terms" => __( "No Colors", "twentyseventeen" ),
"items_list_navigation" => __( "Colors list navigation", "twentyseventeen" ),
"items_list" => __( "Colors list", "twentyseventeen" ),
];
$args = [
"label" => __( "Colors", "twentyseventeen" ),
"labels" => $labels,
"public" => true,
"publicly_queryable" => true,
"hierarchical" => false,
"show_ui" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"query_var" => true,
"rewrite" => [ 'slug' => 'color', 'with_front' => true, ],
"show_admin_column" => false,
"show_in_rest" => true,
"rest_base" => "color",
"rest_controller_class" => "WP_REST_Terms_Controller",
"show_in_quick_edit" => false,
];
register_taxonomy( "color", [ "post" ], $args );
}
add_action( 'init', 'cptui_register_my_taxes_color' );
I'm guessing that the "public" => true
property is important. Let me know how you solve your issue.
Best,
-David
Hi! I activate the plugin and everything looks great! I have a "tag" taxonomie created with ACF and asociated whit docs. But the taxonomies terms appears disabled in frontend. If I enable it, using browser code editor, everything works well, the terms are registered.
What can I do?