I am trying to find the categories of a post, and see if one of them is a specific id. If it is... do something. ELSE, do something else.
My logic is that I need to build a list of the IDs for a post. Then I need to see if one of those IDs is 20. Then do the if/else.
What is wrong with my code below? This is in the loop by the way.
<?php
foreach ((get_the_category()) as $cat) {
$my_cat .= $cat->category_id . ',';
}
echo $my_cat; //FOR DEBUGGING
if ($my_cat == '20') { ?>
<p>DO SOMETHING</p>
<?php } else { ?>
<p>DO SOMETHING ELSE</p>
<?php } ?>