I have a search view with filters on checkbox values, that is no longer working, unfortunately we didn't spot when it stopped working , it could have been several versions of Views ago.
I have a checkbox with a value of 0 or 1 (unselected/selected) - field definition attached.
This is displayed on the search form as a checkbox (attached).
If I select the checkbox on the search form, then no results are returned.
I can see in the search URL that the parameter supplied is in the following format:
special-wellness-status[]=1
If I change the parameter to
special-wellness-status=1
Then the search works correctly.
The search filter shortcode contains the following:
Something doesn't add up in your description above.
The search filter is for a field "special-wellness-status", but the checkbox custom field from your screenshot is "special-wellness-active".
Also the filter control is inserted with the shortcode wpv-control, and I would expect it to be using wpv-control-postmeta for a custom field or wpv-control-post-taxonomy for a taxonomy, perhaps this is an old site.
I suggest you delete the filter altogether and insert it again using the GUI and it should insert the correct shortcode for the correct field and I would expect it to work as intended. If it doesn't, let us know.
(To delete the filter you should delete the markup for that filter from the search and pagination editor as well as deleting the associated Query Filter. If you don't see the Query Filter section, go to the Screen Options tab at the top of the page and make sure it is enabled.)
Hi Nigel,
Well spotted!
Yes, you are quite right, the field in question is special-wellness-status - this is a select (see attached). I think the view is about 4 years old - I deleted the filter as you suggested and created a new one.
This does look as though it should return the value we want: Special wellness status is a number greater than or equal URL_PARAM(wpv-wpcf-special-wellness-status)
We have a single checkbox on the page, which is exactly what we want.
In this case we are interested in returning any post with a value of 1 or 2 for the field.
When I submit search it returns no values. The url parameter looks like : wpv-wpcf-special-wellness-status%5B%5D=1
If I remove the square brackets
Hey Waqar,
Thanks for trying to reproduce this. If I set my filter to 'number is equal to' then yes it does work. But that isn't what had setup originally. So here are the key points:
The filter control on the page is a checkbox with a value of 1 if selected.
The post meta field we are filtering on is a select with the values 0,1,2
We want to return posts where the post meta = 1 or 2
The filter we are using is:
The field Special wellness status is a number that is greater than or equal the following: URL parameter wpv-wpcf-special-wellness-status
So when the checkbox is selected and has a value of 1, then we should return posts with the select value set to 1 or 2
Waqar - I'm happy to give you access to the site. If you could try and reproduce the filter as I have described and it works, I'd be very happy to let you play - I think you can