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)