Wordpress Query based on Checkbox Value -
i'm trying query custom post type of "projects" , return posts have "custom_featured" checkbox checked on. current query, it's not returning although have several posts checkbox checked.
$args = array( 'post_type' => 'projects', 'meta_query' => array( array( 'key' => 'custom_featured', 'value' => 'true', 'compare' => '=' ) ) ); $my_query = new wp_query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <a href="<?php the_permalink();?>"> <h1><?php the_title(); ?> </h1> </a> <?php endwhile; } wp_reset_query();
i figured out. 'value' should "on" , not "true"
Comments
Post a Comment