Plugin Author
TC.K
(@wp_dummy)
Hi,
You can use ‘uwpqsf_taxonomy_arg’ for changing the parameter. The plugin use get_terms() to get all the taxonomy fields. So, any parameter that supported by get_terms(), also can be use for uwpqsf_taxonomy_arg().
Eg.
add_filter('uwpqsf_taxonomy_arg','include_wpsqf_term','',2);
function include_wpsqf_term($args,$formid){
$args['exclude']='';//clear any exclude term id if there any
$args['include'] = array('1,2,3,4,5');//include all the term id you want to add.
return $args;
}
When you use this, note that it will interfere with the ‘search all’ query. So, it is advice not to use ‘search all’ for the field.
Thank you so much! That works- I just had to remove both of the ‘ apostrophes from the include array list. So for others wondering, it should be:
$args['include'] = array(1,2,3,4,5);
Last question- to use this with multiple forms, I tried using the $formid parameter but without luck. I tried adding:
$formid = [your_id_here];
on the line before the return statement, and duplicating the function and filters then using a different $formid and renaming the function, but no luck (it just uses the second function I create, probably because I’m reusing the same filter). Any advice?
Thanks again 🙂
Plugin Author
TC.K
(@wp_dummy)
where did you use the $formid?
I used it in the function, right before
return args;
as well as tried passing it in directly in the parameter, like
function include_wpsqf_term($args,800){
And neither seemed to work.
Sorry for the delay, here it is-
add_filter(‘uwpqsf_taxonomy_arg’,’include_wpsqf_term’,”,2);
function include_wpsqf_term($args,$formid){
$args[‘exclude’]=”;//clear any exclude term id if there any
$args[‘include’] = array(156,157,160,161,159,158);//include all the term id you want to add.
$formid = 779;
return $args;
}
However, even with only one of these blocks (i.e., removing the formid altogether and only using one form) it messes up the other taxonomies I add. So if I try to “include” categories but also allow for custom taxonomies or tags, they only show up as “checkbox”
Thanks for your help!
Plugin Author
TC.K
(@wp_dummy)
try this
function include_wpsqf_term($args,$formid){
if($formid == '779'){
$args['exclude']='';//clear any exclude term id if there any
$args['include'] = array(156,157,160,161,159,158);//include all the term id you want to add.
}
return $args;
}
Hmm, for some reason that doesn’t work at all- all categories are displayed, not just the ones I tried to include.
I don’t have any exclusions set, not that it would matter since they’d be cleared anyway.
You know, we could take this in another direction…when I use:
add_filter(‘uwpqsf_taxonomy_arg’,’include_wpsqf_term’,”,2);
function include_wpsqf_term($args,$formid){
$args[‘exclude’]=”;//clear any exclude term id if there any
$args[‘include’] = array(156,157,160,161,159,158);//include all the term id you want to add.
return $args;
}
The inclusion works, but any other taxonomies I add just render as “checkbox checkbox checkbox”. If we could solve the multiple taxonomy issue, I would probably be OK just having one form.
Plugin Author
TC.K
(@wp_dummy)
I see,
So you have multiple taxonomies in one form. The above script wont work.
The filter ‘uwpqsf_taxonomy_arg’ so far can’t do that. But I will include taxonomy slug as another parameter to the filter in the future update. With this new parameter you can conditionally include the term ids by each taxonomy slug.
However, not sure the update date yet. Hopefully can get it done by this month.
Awesome, thank you! I really appreciate it :]
Just wanted to say, I hope that include rather than exclude is an option for a future update, especially if using multiple taxonomies in one form.
Awesome plugin, really really useful. Include would be amazing, if you choose the tags taxonomy INCLUDE would be a lot better than EXCLUDE. I don’t mind at all paying for such an update, it would be extremely useful 🙂
Thank you kindly and keep up the awesome work,
Chris
If I wanted to opt for INCLUDE, where would I need to paste the code you provided in the second post?
add_filter('uwpqsf_taxonomy_arg','include_wpsqf_term','',2);
function include_wpsqf_term($args,$formid){
$args['exclude']='';//clear any exclude term id if there any
$args['include'] = array('1,2,3,4,5');//include all the term id you want to add.
return $args;
}
Thank you kindly,
Chris
Plugin Author
TC.K
(@wp_dummy)
In your theme functions.php