Tell us what you are trying to do? I am editing a view to add a Query Filter and i'm not sure if it's correct as it doesnt seem to work.
The query filter is based on a Custom Field Group (Private) that uses a check box. If the check box is marked then it has a value of 1.
I want the views to exclude all the posts that are Private, meaning have a value of 1. So I set it up to include all the posts with a value of blank for that specific field.
It doesnt seem to work.
Is there any documentation that you are following? https://toolset.com/documentation/user-guides/views/filtering-views-for-a-specific-text-string-search/
Is there a similar example that we can see? I saw a video tutorial for a similar function where you create a value of 1 for Premium cars.
What is the link to your site?
hidden link
It's pretty difficult to filter out non-existent values from a custom search View. One way you could do it is to create a separate View of those posts with the custom field value = 1, and output a list of comma-separated post IDs. Then you could add a Query Filter in the original View that excludes posts by ID using a shortcode attribute "ids", and place the new View in the original View's ids shortcode attribute. Another option is to use custom code with the wpv_filter_query API to test for a custom field that does not exist. It's a bit tricky when you have a few other custom field filters. I think the post IDs exclusion filter is probably the most straightforward example. Let me know if you have questions about setting that up.
Hi Christian,
I am glad it is you who answered this question. It is actually a follow up to an old one that you also answered:
https://toolset.com/forums/topic/is-it-possible-to-set-some-products-as-private/
> It's pretty difficult to filter out non-existent values from a custom search View.
Maybe the problem is that I have assigned non existent values so I changed the parameters of the Custom Field and assigned a 1 if the checkbox is ticked and a 0 if not, whereas in the last version it had no value.
Please see my adjustments in the screenshot and let me know if I'm doing anything wrong. Basically I want to show all the posts that have a 0 value if not checked.
This is the first time that I use a Query Filter so I want to keep it as simple as possible.
Thank you
I assigned a value of 0 if the box is not checked but the filter doesn't seem to work because all the posts are showing.
Actually the "save 0 if not checked" option should not be used here. We learned this can cause problems for custom search, as explained in this erratum:
https://toolset.com/errata/checkboxes-that-save-0-are-interpreted-as-checked-by-views/
The suggestion from our other ticket about using a radio field is probably the simplest solution to implement if you are just starting a new project, or entering this field data for the first time.