Hi
Did email about this today. I have been getting a lot of questions regarding taxonomy fields, so I want to make a video on it.
What you are going to want to do is create a taxonomy field in ACF. Choose categories as the taxonomy type. Then turn on load terms and save terms and select which caregories you want to show as options. Finally, in the widget select this field and for the “post categories” field choose “None/Custom”.
Please let me know if this works
Regards
Thank you for your quick answer
– I’ve created a STaxonomy Field in ACF and make it display in the form (frondend)
But I can’t find the option in your words “and select which caregories you want to show as options”.
Where to select the categories to display?
Thanks
Hey, my bad this is not actually an option in this field but it should be. Replace {$field_name} on the bottom line with your field name and then put this in your functions.php file in your child theme. Warning, test this on a staging site first.
function my_taxonomy_query( $args, $field, $post_id ) {
// modify args
$args['child_of'] = 'your_main_category_id';
// return
return $args;
}
add_filter('acf/fields/taxonomy/query/name={$field_name}', 'my_taxonomy_query', 10, 3);
Plaese refer to this page for further information: https://www.advancedcustomfields.com/resources/acf-fields-taxonomy-query/
Hi
I tried but it does not work, still display all categories
Will you add this feature to the next release? It’s must have, I can order the pro version to have this feature, cause I have multiple submit forms for multiple groups so can’t use this way to display category for each form.
function my_taxonomy_query( $args, $field, $post_id ) {
// modify args
$args['child_of'] = '131';
// return
return $args;
}
add_filter('acf/fields/taxonomy/query/name=mycustom_category_fieldname', 'my_taxonomy_query', 10, 3);
Thanks