Meta Query not taking empty value

This might be potentially a bug but when working with frontend rendering query, when I tried to exclude a custom field with a specific value, it works but it will not work if the custom field is empty.

For example, I created a custom field called ‘Trending’, by default, this custom field is empty (null). So I wrote a function and cronjob to update this field based on the post age. If more than 3 days, then it will update the field with value ‘no’.

Then in the query setup, Meta Query I set the key ‘trending’ and meta value ‘no’ and Meta compare to !=
(Basically here I’m trying to not show any post that has a meta value of ‘no’ in the Trending field.)

Then the query will return 0 result because they do not put the null value in the consideration, so now I have to expend my function to write if / else statement so in both ways, this custom filed will have values so then the Meta Query will be able to do what I’m exactly looking for.

Hope this makes sense. And also, when we do Taxonomy query to try to exclude a post with a term, it just doesn’t work as we tried all the compare condition like ‘IN, NOT IN, etc’

Environment info

  • WordPress version: 6.2.2
  • Cwicly Plugin version: 1.2.9.7.3