Category Based Post Formats in the Loop?
-
Need some help here, folks. I’m not PHP guy, and am trying to implement a more complex WordPress setup than what I’ve done before.
My goal is a Loop where posts from certain categories are formatted differently (not just style, but actual code, so applying different classes won’t work here). These categories would be 5, 6, and 7. I have a category 8 which is the featured posts that always piggybacks along with category 1 (general purpose blog posts). This will come into play here in a minute.
I have the following set up as my index.php:
<?php get_header(); ?> <?php get_sidebar(); ?> <!-- Start the Loop --> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <!-- Start Category Filter --> <!-- Cat 5 THOUGHTS --> <?php if ( in_category('5') ) { ?> Lorem Ipsum <!-- Cat 6 LINKS --> <?php } elseif ( in_category('6') ) { ?> Lorem Ipsum <!-- Cat 7 VIDEO --> <?php } elseif ( in_category('7') ) { ?> Lorem Ipsum <!-- Normal BLOG Format --> <?php } else { ?> Lorem Ipsum <!-- End Category Filter --> <?php } ?> <!-- 404 Catch --> <?php endwhile; else: ?> Lorem Ipsum <!-- Stop the Loop --> <?php endif; ?> <?php get_footer(); ?>My most recent posts are a category 5 followed by all category 1’s. There is a single category 8, but it is several posts back.
However, when I preview this theme to check my work, the Loop does not display as I’ve intended. Instead of several posts with the category 5 formatted differently, only the single category 8 post is shown and nothing else (but hey, at least is is formatted right!).
Can anyone spot what I’ve done wrong here?
The topic ‘Category Based Post Formats in the Loop?’ is closed to new replies.