I have a post with the following post_meta, dumped using var_dump(get_post_meta(get_the_ID()));

array(6) {
  ["_edit_last"]=>
  array(1) {
    [0]=>
    string(1) "1"
  }
  ["_edit_lock"]=>
  array(1) {
    [0]=>
    string(12) "1495095057:1"
  }
  ["tvs_posts_type"]=>
  array(1) {
    [0]=>
    string(37) "a:1:{i:0;s:19:"tvs-posts-type-post";}"
  }
  ["_tvs_posts_type"]=>
  array(1) {
    [0]=>
    string(14) "tvs_posts_type"
  }
  ["tvs_posts_excerpt"]=>
  array(1) {
    [0]=>
    string(7) "Excerpt"
  }
  ["_tvs_posts_excerpt"]=>
  array(1) {
    [0]=>
    string(17) "tvs_posts_excerpt"
  }
}

And as you can see there’s a tvs_posts_type key with the value a:1:{i:0;s:19:"tvs-posts-type-post";}.

Using ‘meta_query’ I was hoping I could just the do the following:

'meta_query' => array(
       array(
          'compare' => 'IN',
          'key' => 'tvs_posts_type',
          'value' => 'tvs-posts-type-post',
      ),
  ),

But this does not show my post. Interesting though, when I change it to ‘NOT IN’ it does show. Even though the tvs-posts-type-post value is present in the tvs_posts_type.

What am I missing here?

Read more here: Comparing key/value with "IN" using meta_query for serialised post_meta


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: