Hello, I am doing a view filtering by custom fields (this: https://toolset.com/documentation/legacy-features/views-plugin/passing-arguments-to-views/), and this custom field can have one, two or more values and I pass this information with a shortcode attribute. How can I do this?
Example:
I have elements with a field called "valor" with values: "1", "2" or "3"
In the view shortcode, how can i pass values "1" and "2" ?
These examples don't run:
[wpv-view name="view-test" valuesforfilter="1;2"]
[wpv-view name="view-test" valuesforfilter="1&2"]
[wpv-view name="view-test" valuesforfilter="1,2"]
Only works if i pass only one value:
[wpv-view name="view-test" valuesforfilter="1"]
or
[wpv-view name="view-test" valuesforfilter="2"]
Hello,
How do you setup the custom field "valor"? a custom select field? how do you setup the filter in post view? can you take a screenshot for it?
I need to test it in my localhost, thanks
It is a select custom field (screenshot part1), (but it could be a checkbox custom field and could have one or more values selected)
View filter setup is like screenshot part 2, and it works only if value "tarifascontratadasqueaparecen" is one
This works ok
[wpv-view name="view-test" tarifascontratadasqueaparecen="1"]
How can i do that this works correctly?:
[wpv-view name="view-test" tarifascontratadasqueaparecen="1,2"]
Thanks for the details, you can use "IN" Comparison function in the filter, for example: edit the post view, setup the filter as below:
my-field is a string in VIEW_PARAM(tarifascontratadasqueaparecen)
Then setup view's shortcode like this:
[wpv-view name="view-test" tarifascontratadasqueaparecen="1,2"]
More help:
https://toolset.com/documentation/user-guides/views/filtering-views-by-custom-fields/
IN: A list of values Checks if the custom field value is within the list of compare values
Problem solved. Thank you!!!