Skip Navigation

[Resolved] Filter on empty or null or not-exist

This thread is resolved. Here is a description of the problem and solution.

Problem:
How can we query a View by empty or not existing fields?

Solution:
Currently we cannot

There is however a feature filed to allow it in future following this idea:
The comparison in the query should end up like:

array( 
    'key' => 'wpcf-price', 
    'compare' => 'NOT EXISTS'
)

When we will implement this is not yet determined - please add a message to this thread if you wish to add your voice to the request.

This support ticket is created 7 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 10 replies, has 4 voices.

Last updated by tylerG 7 years, 2 months ago.

Assisted by: Beda.

Author
Posts
#549846

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

#550021

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.

#560338

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.

#560779

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.

#561108

It would be great. "not exists" is something I need many times.

#561129

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?

#563698

If it doesn't mean it will be forgotten ...

#563796

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.

#563814

🙂

#563816

I will close here, Tina, is that OK?

Please do not hesitate to contact us in the forums if any other issues appear 🙂

#1167387

I would love to see this feature as well. Has there been any progress?