Ok, I’ve been looking all over the place and I can’t seem to figure out exactly how to do this.
What I want to do is to have a home page that has some static text, and a loop (mini?) displaying the posts only from one category.
I came up with this:
<?php if (!in_category(7)) continue; ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<?php the_content("Continue reading the " . the_title('', '', false) . " article"); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
This, I thought, worked fine, until I started adding more content! It does the trick if, and only if, the posts in the news category (ID=7) are the very latest in date.
So, how would I do it? Create the home page loop so it only looks up one category, and displays the posts from that category, regardless of more recent posts in other categories?
Any ideas would be very welcome
- The topic ‘Home.php loop for only one category?’ is closed to new replies.