• 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)
  • check this 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.

    <?php get_archives('postbypost', 6); ?>

    But the function is deprecated…

    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

    (@eddie_v)

    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() but might have to just hack the core function.

    Could use this plugin https://www.ads-software.com/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 is you need a widget.

    Thread Starter eddie_v

    (@eddie_v)

    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.