How to add last 3 posts on pages?
-
I would like to add the last 3 posts from a certain category on all pages from my blog. The problem is that I want to add them BEFORE the content and I get an error. My current code is:
<div id ="box" here should be the last 3 posts> <?php query_posts('cat=2&showposts=3'); ?> <?php while (have_posts()) : the_post(); ?> <h2> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <div class="entry"> <?php the_content_limit(200); ?> <br /> <?php endwhile;?> <div class="clear"></div></div> </div> </div> </div> <div id="contentbox" here should be the content of the page> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="entry"> <?php the_content('Read more...'); ?> <div class="clear"></div> </div> <?php endwhile; else: ?> <?php endif; ?>
What I’m doing wrong there? ??
- The topic ‘How to add last 3 posts on pages?’ is closed to new replies.