How to create a meta_query (if any checked) for multichoice checkbox meta field?
-
Right now I have this code to grab only that posts that are in category called news and at the same time have checked at least one option from multiple choices checkboxes in meta field called post_second_league
MY CODE:
<?php $args = array( 'category_name' => 'news', 'meta_query' => array( array( 'key' => 'post_second_league', 'value' => TRUE, 'compare' => 'LIKE' ) ), 'posts_per_page' => 5 ); query_posts( $args ); ?>
But it do not reflect my meta_query condition ;( and get all the posts in category news.
If I try to print_r() the meta info:
<?php $meta = get_post_meta( get_the_ID() ); ?> <?php print_r($meta); ?>
I get for the post’s meta field post_second_league this output:
[post_second_league] => Array ( [0] => a:1:{i:0;s:0:"";} )
I guess my condition is wrong and I need to use different check than TRUE for value and maybe also compare LIKE is wrong too?
Thanks for any advice how can I get only posts that have checked at least one option from this multichoice checkbox field with key post_second_league.
- The topic ‘How to create a meta_query (if any checked) for multichoice checkbox meta field?’ is closed to new replies.