views:

13

answers:

2

Hi,

I only want to return the latest 2 posts but my code returns all the posts, any idea how I can fix this?

Code below,

Thanks,

R.

<?php
 $postslist = query_posts('posts_per_page=2');


 foreach ($postslist as $post) : 
    setup_postdata($post);
 ?> 
 <div class="post">

 <?php the_date('d/m/y', '<div class="date">', '</div>'); ?>

 <?php the_title('<div class="title">', '</div>'); ?>   
 <?php the_excerpt(); ?>
  <?php echo '<a class="readmore" href="'. get_permalink() . '">' . __( 'Read More <span class="meta-nav">&raquo;</span>', 'twentyten' ) . '</a>';?>
 </div>
 <?php endforeach; ?>
A: 

Try:

query_posts( array( 'posts_per_page' => 2 ) );
fredley
A: 

You should be able to accomplish this easily through the WP admin panel.

Go to Settings -> Reading -> and then change the number in the box next to "Blog pages show at most" to 2.

Does that solve the issue?

Libby