Post Meta Key – If Key = empty or null?

Forums › Forums › Search & Filter Pro › Post Meta Key – If Key = empty or null?

Tagged: 

Viewing 3 posts – 1 through 3 (of 3 total)
  • Anonymous
    #188713

    Hey there,

    I have a form that searches for a post meta key through a drop-down. If key value = true then these posts will be displayed. Easy enough and works perfect.

    But, if I want to say that this specific key has a value of null or that it doesn’t exist in the post, then is this possible?

    I tried doing it with a value of null but it made no posts show up.

    Trevor
    #188714

    It can’t be done, at least not that way. This is not an uncommonly asked question, to which I have not seen an answer that works. The logic is OK, but WordPress doesn’t store data in this way. If a meta key has no data for a given post, there is no entry at all in the database for it, so there is nothing to check to see if it is empty.

    This is quite common practice in related tables coding, to save space.

    Anonymous
    #188716

    Thanks for the response Trevor. I had a feeling that was the answer alright. I think I just secretly hoped there was some magic to make it work 😛

    Thanks for the response!

Viewing 3 posts – 1 through 3 (of 3 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.