php - Use ACF checkbox value array to find "More like this" -
i'm using acf checkbox designate categories (called "aims") psychology apps/sites. values be, say, "mindfulness", "well-being" , "depression".
since it's possible select multiple values, i'd have more single post show other posts match 1 or more of categories of post.
update: here's code i'm using now, i'm still not having luck with:
the_field( 'aims'); /* since i'm on page single post, gives me aims current post , returning values checkbox multiple selections (as array, believe) */ $args = array( 'numberposts' => -1, 'post_type' => 'program', 'post_status' => 'publish', 'meta_query' => array( 'relation' => 'and', array( 'key' => 'aims', 'value' => 'well-being', /* i'd use aims current post, i've hard-coded testing, , not seeing results */ 'compare' => 'in') )); $more_like_this = new wp_query ($args); while ($more_like_this->have_posts()) : $more_like_this->the_post(); $star_rating = get_field('overall_score'); ?> <?php the_title(); ?> <?php echo $star_rating ?> <?php endwhile; wp_reset_query(); ?>
Comments
Post a Comment