Title: wp_get_recent_posts includes drafts?
Last modified: August 19, 2016

---

# wp_get_recent_posts includes drafts?

 *  [eddie_v](https://wordpress.org/support/users/eddie_v/)
 * (@eddie_v)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/wp_get_recent_posts-includes-drafts/)
 * I was pretty uneasy to see our code go live and a bunch of drafted posts pulled
   into the wp_get_recent_posts() list I put in the sidebar.
 * And then I noticed you could click on these headlines to see the actual draft.
   Mortifying! Anyone else come across this oddity?

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

 *  [shatterjack](https://wordpress.org/support/users/shatterjack/)
 * (@shatterjack)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/wp_get_recent_posts-includes-drafts/#post-1351343)
 * check [this](http://www.smashingmagazine.com/2008/12/18/8-useful-wordpress-sql-hacks/)
   page out about how to delete post revisions. I found that wordpress keeps all
   the draft versions of a post. There’s a value in the post table of the database
   for post_type=post for the actual post and draft for the drafts.
 *  [Clayton James](https://wordpress.org/support/users/claytonjames/)
 * (@claytonjames)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/wp_get_recent_posts-includes-drafts/#post-1351347)
 * `<?php get_archives('postbypost', 6); ?>`
 * But the function is deprecated…
 * [Template Tags/wp get archives](http://codex.wordpress.org/Template_Tags/wp_get_archives)
 * `<?php wp_get_archives('type=postbypost&limit=10&format=html'); ?>`
 * – Displays last 10 posts in html list format
 *  Thread Starter [eddie_v](https://wordpress.org/support/users/eddie_v/)
 * (@eddie_v)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/wp_get_recent_posts-includes-drafts/#post-1351510)
 * Thanks for the replies. Both are promising, but I can’t tell if they’ll deliver.
   I want to do a 10 post offset.. hoping I can get away with using [wp_get_archives()](http://codex.wordpress.org/Template_Tags/wp_get_archives)
   but might have to just hack the core function.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/wp_get_recent_posts-includes-drafts/#post-1351522)
 * Could use this plugin [http://wordpress.org/extend/plugins/query-posts/](http://wordpress.org/extend/plugins/query-posts/)
   though not sure if offer offset.
 * Or use a version of this code in a sidebar.php
 *     ```
       <?php
           $args=array(
             'offset' => 10,
             'post_type' => 'post',
             'post_status' => 'publish',
             'posts_per_page' => -1,
             '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
             endwhile;
           }
       wp_reset_query();  // Restore global post data stomped by the_post().
       ?>
       ```
   
 * The above could also be put in [Otto’s PHP Code Widget](http://wordpress.org/extend/plugins/php-code-widget/)
   is you need a widget.
 *  Thread Starter [eddie_v](https://wordpress.org/support/users/eddie_v/)
 * (@eddie_v)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/wp_get_recent_posts-includes-drafts/#post-1351679)
 * What a great help. Thanks Michael!

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

The topic ‘wp_get_recent_posts includes drafts?’ is closed to new replies.

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

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
