What I want to accomplish
I need an aside to pull the last 5 posts from a specific set of 5 categories.
Not the latest of each, not the last 5 of each, but the last 5 total posts from the 5 categories.
The category IDs are: 89,90,91,92,93
I have 5 different category pages, so this has been making it trickier. Each of these uses an include for the aside. I am writing that logic in that include.
<?php if ( in_category( 92, $post_id ) ) : ?> $bfaCat = 'bfa-cat-ba'; <?php endif; ?>
Then I have to loop through. Not applying anything if the post is not in any of the categories. But if the posts are of that category then add a variable (as
$bfaCat) with the following class (on right) applied if it has the following category id (on left)
89 - bfa-cat-bl 90 - bfa-cat-fs 91 - bfa-cat-s1 92 - bfa-cat-ba 93 - bfa-cat-ea
HTML - ATTEMPT 1 - in template
<div class="bfa-category <?=$bfaCat;?>"> <?php the_category(); ?> </div>
HTML - desired output example
<div class="bfa-category bfa-cat-bl"> <?php the_category(); ?> </div>
HTML - ATTEMPT 2 - Would this be better if modified?
I know this is sloppy but I also tried it inline but it just applied this class to everything
<div class="bfa-category <?php if (get_category('91')) echo 'bfa-cat-s1'; ?>"> <?php the_category(); ?> </div>
So it seems like the class is being echoed into everything.