Problem styling based on category
-
I am trying to style an h2 based upon what category the post is in.
I have made this code and placed it within the loop and all works well…for the first of each ‘cat_name==’. As soon as a 2nd/3rd/etc post is categorized as ‘Branding’, those subsequent posts dont get styled at all.
<?php foreach((get_the_category()) as $category) { if ($category->cat_name == 'Branding') { echo the_date('m/d', '<h2 class="postDateBrnd postBar">', '</h2>'); } elseif ($category->cat_name == 'Consulting') { echo the_date('m/d', '<h2 class="postDateCnslt postBar">', '</h2>'); } else { } ?>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Problem styling based on category’ is closed to new replies.