Support » Fixing WordPress » List Draft Posts to Public

  • Is there a way to list drafts (simply as bulleted titles) to put in my sidebar, so public viewers know what is coming up?

    Something similar to the list recent posts parameter, but for drafts.

    Spare me the morality of the “draft post” — I know drafts are not supposed to be viewed to the public, but I just want to list the titles — and if I don’t want a draft listed to the public, I can put it as “private” instead.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Dropped a bit of code for such here:

    I don’t know of a more convenient way than to tap into your WordPress database more or less directly:

    <?php $my_drafts = $wpdb->get_results("SELECT post_title FROM $wpdb->posts WHERE post_status = 'draft'");
    $my_draft_list = '';
    foreach ($my_drafts as $my_draft) {
    if ($my_draft->post_title != '') {
    $my_draft_list .= '<li>' . $my_draft->post_title . '</li>';
    echo $my_draft_list;

    EDIT: Kaf beat me :)

    Now that’s what I like about these forums. That’s something I’d never even thought of doing, but as soon as I read it, I thought “oooh, I lke that”.

    What I’d like to see (and I think I’ll have a go myself, might learn some PHP in the process, can’t be a bad thing) is to group the list by post category. So you could have “Coming soon in Wibble[1]” or “Coming soon in Burble” and so on. Thanks for the idea, and the code, guys 🙂

    [1] Or whatever your categories are

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘List Draft Posts to Public’ is closed to new replies.