Title: Recent Posts showing drafts
Last modified: August 19, 2016

---

# Recent Posts showing drafts

 *  [daenterpri](https://wordpress.org/support/users/daenterpri/)
 * (@daenterpri)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-showing-drafts/)
 * Hello,
 * I’m using the following code to show my recent posts. However, it’s also showing
   the titles of our drafts.
 *     ```
       <?php
                 $number_recents_posts = 10;//Can be how much you want
                 $recent_posts = wp_get_recent_posts( $number_recents_posts );
                 foreach($recent_posts as $post){
                   echo '<li><a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' .   $post["post_title"].'</a><br /><div class="newsdate">Posted: '.$post["post_date"].'</div></li> ';
                 } ?>
       ```
   
 * Any idea how to exclude drafts or only show published titles?
 * Thanks,
 * Andy

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-showing-drafts/#post-1707193)
 * Try:
 * `$recent_posts = wp_get_recent_posts( 'post_status=publish&numberposts=' .$number_recents_posts);`
 *  Thread Starter [daenterpri](https://wordpress.org/support/users/daenterpri/)
 * (@daenterpri)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-showing-drafts/#post-1707346)
 * Thanks for the suggestion! Unfortunately it didn’t work.
 * Any ideas?

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

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [daenterpri](https://wordpress.org/support/users/daenterpri/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-showing-drafts/#post-1707346)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
