I've Broken My Loop!
-
Heya WP gurus, I could sure use some help here.
This is my first time dealing with WordPress 3 (using 3.0.1) and somehow I’ve managed to completely mangle up my Loop. 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!).
You can see this in effect at http://4xlt.willphillips.org/.
My chief finding thus far is that the Loop displays only the first post from category 8 (or has the Feature category along with another). It isn’t a multiple category problem, as a post with any two other categories won’t be displayed.
However, when I set an elseif(in_category(‘Feature’)){} specifically for the Feature category, it seems to ignore it and goes back to the default format of the else{} and still only displays that single post.
I have a few suspicions:
1. Have I inadvertently bungled my PHP (I’m a hack at best)?
2. Is there a WordPress feature/bug I’m missing?
3. I have three different query_posts set up in the page (one in the header and two in the sidebar) – can those mess up the Loop?
4. Have I failed to include some code somewhere?Can anyone spot what I’ve done wrong here? I really, really need some help.
The topic ‘I've Broken My Loop!’ is closed to new replies.