I am trying to setup a view filter to returns posts with empty/null/not-exist meta key
I tried to set string = '' and boolean true/false but nothing worked.
Ended up with a conditional display instead but this is not the optimal solution for performance reasons.
The comparison in the query should end up like:
array(
'key' => 'wpcf-price',
'compare' => 'NOT EXISTS'
)
Note:
NOT EXISTS is just like what it sounds - the meta value isn't set or is set to a null value. All you need for that query is the key and comparison operator:, Since WordPress 3.5
Also EXISTS comparison is missing ...
I can see that this was asked for in July 2016, but I am unable to find an answer on if this has been implemented.
https://toolset.com/forums/topic/cant-use-query-filter-to-test-for-empty-select-value/#post-418708
Hi Tina, let me ask what the status is on filtering by 'EXISTS' and 'NOT EXISTS'. I do not see it in the current list of feature requests, so I'm not sure if that means it was proposed and declined, or if there is ongoing discussion. I'll update you when I have some more information.
Hi, I'm going to assign this ticket to Beda, our Views feature request liaison, so he can continue to monitor the discussion about your request. He will continue to follow up with you here.
Hello, Tina.
The request is filed.
I have not yet any Updates on this but it makes sense and I will ask if in the next Development cycle we can add the possibility to do that.
It would be great. "not exists" is something I need many times.
I filed it, yes.
And yes, I understand it is important.
Feature Requests take a while to be added.
I suggest we close here, and you can follow the Blog, or our Changelog, for implementation notices.
Would you agree?
If it doesn't mean it will be forgotten ...
It won't be forgotten.
I filed this on my internal sheet, where I count votes of each feature, also evaluate their importance and if it affects other users, and from there it makes its way to the Developers daily work to implement this requests-
I cannot state an ETA for this, but I will try to push for it, the feature makes a lot of sense to me as well.
I will close here, Tina, is that OK?
Please do not hesitate to contact us in the forums if any other issues appear 🙂
I would love to see this feature as well. Has there been any progress?