Hello. Thank you for contacting the Toolset support.
As I understand, you must have created view with filters and you want to assign the custom URL param for your search filters.
You said:
I get 0 returns when using these searches:
- enlace oculto
- enlace oculto
==>
Its not logical to assign the same URL param for color and size (as you done src) as both filters are having different values. The URL params must be unique.
So, if you add a filter with:
- enlace oculto
- enlace oculto
===>
Notice that src1 and src2 are different URL params and you will have to adjust the URL prams with the Query Filter section of your view.
Hi, I know that with 2 different URL parameters work (that's what I use normally), but my question was exactly on why it doesn't work, when using the same URL parameter for all filters.
Let's say I am selling t-shirts and I set these search filters:
color -> string = URL Parameter "src"
OR
size -> string=URL Parameter "src"
The URL
<em><u>enlace oculto</u></em>
should deliver all t-shirts which color="M" OR size = "M"
It probably won't find any t-shirt with a "M" color, but it should output all t-shirts size "M", as we are using the OR operator.
Why I get zero results instead? This doesn't seem logical.
I just run a test and with classic view we have option to modify the URL param but not with block view.
I would like to have bit more information.
How do you setup your view, using blocks or classic views?
Can I have problem URL where I can see the issue and admin access details? Let me see what query is generated.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I just checked your view's settings and I found that we have a known issue when you set OR clause between multiple custom fields or taxonomy as well as we have another issue with checkboxes field type when you pass the URL param from URL.
However, I've workaround to share for that, I've added the following view's hook to "Custom Code" section offered by Toolset:
=> enlace oculto
add_filter( 'wpv_filter_query', 'func_adjust_filter_relation', 1000 , 3 );
function func_adjust_filter_relation( $query_args, $view_settings ) {
if ( !is_admin() && ( isset($view_settings['view_id']) && $view_settings['view_id'] ==2688) ) {
$query_args['meta_query']['relation'] = 'OR';
$target_field = "wpcf-obj-view"; // change this field slug to your field slug
if(isset($_GET['src']) and !empty($_GET['src']) ) {
foreach ($query_args['meta_query'] as $k => $v):
if (isset($v['key']) and $v['key'] == $target_field){
$query_args['meta_query'][$k]['value'] = $_GET['src']; }
endforeach;
}
}
return $query_args;
}
Thanks for your help, but still doesn't work properly.
I have added now another OR custom field "Pool" and I get again zero results.
The problem is that is not really viable to edit the custom code every time we add a filter item.
IMHO the complete operator logic of the Views filter should be revisited.
Every day the expectations of customers are getting more and more complex, so we should expect more Views filters flexibility.
Thanks for your help, but still doesn't work properly.
I have added now another OR custom field "Pool" and I get again zero results.
==>
The thing is that with checkboxes custom field we have a known filtering issue when you try to filter the view result for the checkboxes custom field using URL param that is added directly from URL, in your case src=somevalue.
The known issue is files since long and our devs yet wont able to reach there or there is no fix available that is why I try to share the workaround with you. You will require to tell me what fields you want to filter with so that I can share working workaround with you.
In this particular case, the customer add/remove search parameters regularly.
The best way would be if the code would include an array of custom fields, which is easier to change/maintain.
Yes - we can add array of custom fields but you will require to tell me what fields you want to include.
However, As far as I know, the issue will only happen when you try to add the field whose field type is checkboxes. Other fields should work OK and until now, we only have issue with checkboxes field type.
So, if you agree, you can send me array of checkboxes field type you want to include and I will try to adjust the code accordingly.