dimanche 10 novembre 2019

Get exact match of taxonomy terms, not a partial match

I have set up a loop to display content for an EXACT match of two taxonomy terms. However, the code I have used is including results with partial matches. How do I adjust the IF statement so it only shows the exact matches?

For a little context I should only get results when the age group is exactly 1st and 2nd grade. Not those that include 1st and 2nd grades along with other grades.

Here is the code I have been using:

<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>

Aucun commentaire:

Enregistrer un commentaire