Hi @tnightingale
I hope you are doing well.
It will require some custom coding.
To show / hide specific categories:
add_filter( 'forminator_field_postdata_category_list', function( $categories ){
$exclude_cat_ids = [
123,
456
];
if( $exclude_cat_ids ){
foreach( $categories as $id => $cat ){
if( in_array( $cat->term_id, $exclude_cat_ids ) ){
unset( $categories[ $id ] );
}
}
}
return $categories;
} );
add_filter( 'forminator_field_postdata_category_list', function( $categories ){
$only_cat_ids = [
123,
456
];
foreach( $categories as $id => $cat ){
if( ! in_array( $cat->term_id, $only_cat_ids ) ){
unset( $categories[ $id ] );
}
}
return $categories;
} );
So you can use that code to filter the categories that you would like to show or not.
Let us know if you have any additional questions.
Best Regards
Patrick Freitas
At first it did nothing but then I got it working after I changed:
forminator_field_postdata_category_list
to
forminator_field_postdata_country_list
for the filter name – since this is for a custom taxonomy ‘country’.
Thank you.
I want this to only apply to certain forms – best way to do that?
Hi @tnightingal,
I want this to only apply to certain forms – best way to do that?
Seems like your query is similar to what you have asked it your other ticket. I have already replied in your ticket:
https://ww.wp.xz.cn/support/topic/autocomplete-option-for-taxonomy-selection-in-post_data/#post-15887917
Please check and see whether it fits your requirement.
Kind Regards,
Nithin
Yes thank you – and thanks for posting the link so others can find the solution there as well.