I have created a loop to display programs. One of the taxonomies for each program is a grade or grades. Some programs are for 1st and 2nd graders, for example. I would like to display a div in my results that says "Grades 1-2". However, the code I am using is displaying this logic for the programs that are Grades K-2 and K-6, since they include grades 1 and 2 as well. How can I adjust the IF statement so that it only displays camps that have exactly grades 1 and 2?
Here is my code:
<div class="sc-age-group">
<?php
$agegroup = wp_get_post_terms(get_the_ID(), 'camper_grade');
if ($agegroup) {
foreach ($agegroup as $group) {
if ($group->name == "1st Grade" && "2nd Grade") { ?>
<div class="sc-age-group_1-2">Grades 1-2</div> <?php ;
}
}
}
?>
</div>