Problem:
How to only include posts in the results of a View where a custom field equals some value, but where the custom field might not exist for some posts.
Solution:
If you use the != comparison with a custom field filter it will exclude any posts where the field is not set, in which case you would need to modify the View arguments using the API to add a test for whether the field exists. (That's how WordPress queries work.)
An example of such code is given below: https://toolset.com/forums/topic/show-all-others-but-those-who-has-certain-value-in-radio-field/#post-1259327
The client decided to use a taxonomy instead which doesn't have this same problem.
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 |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
This topic contains 2 replies, has 2 voices.
Last updated by 5 years, 5 months ago.
Assisted by: Nigel.