list recent posts in category
-
I’m trying to make a list of recent posts, by date, in one category. I *think* I’m on the right track with this, but i’m not getting the result I expect. Can someone who is more familiar with the workings of the loop help me out?
This is the result I want:
Date
– title of post
– title of post
Date
– title of post
– title of post… and so on for 7 days total …
What I’m getting is more like this:
September 9
– title of post
– title of post
– title of postIt’s showing the posts for the last seven days, but for all categories, and not breaking them down by date. Can anybody tell me where I’m going wrong?
This is the code I have:
<?php $posts = get_posts( "category=2&days=7" ); ?>
<?php if( $posts ) : ?>
<div class="recent">
<h2>Recent album reviews</h2><h3><?php the_time('F j'); ?></h3>
<ul>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<li><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li><?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
- The topic ‘list recent posts in category’ is closed to new replies.