Title: Recent Posts
Last modified: August 19, 2016

---

# Recent Posts

 *  [uteman23](https://wordpress.org/support/users/uteman23/)
 * (@uteman23)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-2-2/)
 * Hi, I am trying to get the title of the five most recent posts with the number
   of comments in my footer. I don’t want to use the widget. What is the code to
   do this.
    I have tired <?php query_posts(‘showposts=5&orderby=date’); ?> But 
   nothing shows up
 * Thanks

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

 *  [kwbridge](https://wordpress.org/support/users/kwbridge/)
 * (@kwbridge)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-2-2/#post-986742)
 * To run php code in pages, posts, and text widgets you need to use a plugin like
   Exec-Php
 * [http://wordpress.org/extend/plugins/exec-php/](http://wordpress.org/extend/plugins/exec-php/)
 *  [revilo999](https://wordpress.org/support/users/revilo999/)
 * (@revilo999)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/recent-posts-2-2/#post-987087)
 * I am also trying to use the recent posts but by adding them to my home page outside
   wordpress then when visitors click on ant post it takes them to the wordpress
   articles. Any help would be appreciated.
 *  [borellidesigns](https://wordpress.org/support/users/borellidesigns/)
 * (@borellidesigns)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/recent-posts-2-2/#post-987090)
 * @ revilo999: I don’t believe you can call a WordPress function outside of the
   loop. Try utilizing a feed reader to accomplish this.
 * [@uteman23](https://wordpress.org/support/users/uteman23/): Try using this code
   to call the top most recent headlines
 *     ```
       <?php
           $recent_posts = new WP_Query();
           $recent_posts->query('showposts=5');
       ?>
       <?php while ($recent_posts->have_posts()) : $recent_posts->the_post(); ?>
           <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
       <?php endwhile; ?>
       ```
   
 * This should pull the title for you. You can also pull the excerpt if you’d like
   by using adding this code:
    `<?php the_excerpt(); ?>`
 * Style however you’d like.

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

The topic ‘Recent Posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 4 participants
 * Last reply from: [borellidesigns](https://wordpress.org/support/users/borellidesigns/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/recent-posts-2-2/#post-987090)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
