Problem: I have a checkbox field set up to "save 0 to the database" when unchecked. I would like to edit that field to save nothing when unchecked, I would like to know what I need to change in the database to update my existing posts, and I would like to know how to update an existing View filter to show only items with the checkbox field unchecked.
Solution: Since there is no serialization involved with single checkboxes, you can simply delete all the "0" entries from postmeta for this meta_key. Then in the custom field editor screen, change the checkbox setting to save nothing when unchecked. It's not simple to create a View that filters by an unchecked checkbox. You can use the wpv_filter_query API to modify the meta_query criteria to use "NOT EXISTS" in the comparison field.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 10 replies, has 4 voices.
Last updated by 5 years, 10 months ago.
Assisted by: Christian Cox.