WordPress.org

Ready to get started?Download WordPress

Forums

List Draft Posts to Public (4 posts)

  1. ralph
    Member
    Posted 9 years ago #

    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.

  2. Kafkaesqui

    Posted 9 years ago #

    Dropped a bit of code for such here:

    http://wordpress.org/support/topic/29485#post-166205

  3. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

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

    <ul>
    <?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;
    ?>
    </ul>

    EDIT: Kaf beat me :)

  4. lbessant

    Posted 9 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags