Title: Last 5 entries coding?
Last modified: August 19, 2016

---

# Last 5 entries coding?

 *  Resolved [ohdiesel](https://wordpress.org/support/users/ohdiesel/)
 * (@ohdiesel)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/last-5-entries-coding/)
 * Hello!
 * Anyone have php code for the first 5 entries that I can list on my blog page?
 * I want to list the latest 5 entries on my site, but as it is now, I am using 
   only get_post which cannot do what I want it to.
 * Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/last-5-entries-coding/#post-1380110)
 * Well `get_posts` should work but try:
 *     ```
       <?php
       $args=array(
         'post_type' => 'post',
         'post_status' => 'publish',
         'posts_per_page' => 5,
         'caller_get_posts'=> 1
       );
       $my_query = null;
       $my_query = new WP_Query($args);
       if( $my_query->have_posts() ) {
         echo 'List of Posts';
         while ($my_query->have_posts()) : $my_query->the_post(); ?>
           <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           <?php
           the_content(); //delete this if you only want post titles
         endwhile;
       }
       wp_reset_query();  // Restore global post data stomped by the_post().
       ?>
       ```
   
 *  Thread Starter [ohdiesel](https://wordpress.org/support/users/ohdiesel/)
 * (@ohdiesel)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/last-5-entries-coding/#post-1380327)
 * Muchos gracias

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Last 5 entries coding?’ is closed to new replies.

 * 2 replies
 * 2 participants
 * Last reply from: [ohdiesel](https://wordpress.org/support/users/ohdiesel/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/last-5-entries-coding/#post-1380327)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
