List Draft Posts: a WordPress plugin

As of March 2011, I am officially abandoning development of this plugin – anyone who wants to adapt it to do something more, something different, or indeed to write a version that won’t make real coders cry, is more than welcome to do so. There will be an update of the widget version soon, though.

Quite some time ago, I revealed to the world my first attempt at a WordPress plugin: Coming Soon. This was a very basic thing that just listed the titles of all draft posts. This is the sort of thing that’s of little or no interest to most WordPress users, but I like to have it in my sidebar to tease readers with hints of things to come, and to remind me of things I need to get on with writing.

The first version had everything hard coded – if anyone wanted to use it for their own purposes, they’d have had to edit the PHP, which was a bit messy. A later version actually used parameters for the function, which would have made things a little easier, but still wasn’t that friendly. But as I was the only one using it, this didn’t seem all that important.

But on Friday evening, I was looking at the WordPress Support Forums when I saw someone asking for advice on developing plugins, which led me to this really nice article by Leonid Mamchenkov on how to make options pages for WordPress plugins, and this piece by Mark Jaquith on how to make such things more secure[1].

And so I started fiddling. And, err, several hours later, I had a new version of my plugin, which has an options page for setting the title for the section, the text used for untitled posts and the HTML tags that surround it all. By default, the plugin’s output is set to be an item in an unordered list. The heading is a <h2>, and the titles form an unordered list. That should work for the sidebar in most WordPress themes, but if it needed to be in a <div>, or some other formatting, then changing it is now a simple matter of changing the options.

As it’s pretty much a new plugin, I decided to rename it to the rather more descriptive List Draft Posts, and changed the function name to match.


If this looks like something you would like to use, you can download it from the official WordPress Plugins Directory. Woo.


Unzip and upload the lcb_list_draft_posts.php to your WordPress plugins folder. Activate the plugin in the usual way, then look at the List Draft Posts page under Options. Unless you have special requirements, you will probably only need to change the Heading and Description for untitled drafts options. Click the Update options button to save your changes.


Include the following code at a suitable point in your sidebar:

<php if (function_exists('lcb_ldp')) lcb_ldp();?>

Create a new post, save it without publishing and you should see a list in your sidebar. If there are no draft posts, nothing should appear.


Time passes, and all that. I have since created a widget version of this plugin.


Add a comment to this post, and I’ll look into it as soon as I can. I should mention that I’m not really a coder, so this plugin may not be doing things in the best or most efficient manner, and may drink all your wine or eat your chocolate when you’re not looking. This version has only been tested on WordPress 2.3, but it should play nicely with anything above WordPress 2.0.x.


Until now, I hadn’t realised just how nifty WordPress’s system for allowing plugins to add themselves into the admin interface was. Using the instructions I mentioned earlier, a non-coding person like me was able to make it work with only a few mistakes along the way. Of course, writing more complicated and useful plugins is another matter altogether, and is best left to people who actually know what they’re doing.

[1] Note to UK readers: this article uses a slightly unfortunate expression for a number used once. This has caused some amusement. It’s that thingy about two countries separated by a common language again…

18 thoughts on “List Draft Posts: a WordPress plugin

  1. Pingback: WP插件:List Draft Posts-日志èç¨¿åˆ—表 | 帕兰的口袋

  2. Jonathon

    Alas, my drafts include items which I do not want to list publicly.

    1. “Test” posts and pages. I have a category of published Tests, to show my non-technical business partner, but I want these other tests for my own reference. I suppose I could create another category called Tests2 for these, and use Advanced Category Excluder and a feed modification to make them invisible.

    2. Experimental Posts – a scrapbook of things that I think could become posts, but may not. I don’t want these marked Coming Soon, or even Drafts – I don’t want to clutter my reader’s mind with more than the truly good coming posts.

    3. Removed Posts – posts which were published but I removed because they needed re-wording/research/reconsideration – they may or may not be published again – I don’t want to delete them, quite, but I don’t want them to appear publicly as drafts.

    Could there be an opt-in/opt-out button for different posts? In the wp-admin area, under the Manage section, could there be a list of drafts, all selected by default, but which we can un-check to remove from display in our list?

    The plugin Page Link Manager (
    does something like this, allowing published pages to appear or not appear in the wp-list-pages list. It has a checkbox in the write/edit page/post pages, as well as a list of all pages accessed via the Manage section of wp-admin, titled “Page Links”.
    Perhaps its creator, Garrett, could easily help modify List Draft Pages to have those features.

    I think that would be the best route, but there are other similar plugins, such as:

    Advanced Category Excluder
    “With this plugin you can define categories for some parts of the site to be hidden. By Zsolt Lakatos (DjZoNe).”

    (By the way, I’ll see if I can find an appropriate place on to suggest Draft Subcategories.)


  3. Les Post author

    All good points, Jonathon. A more sophisticated and configurable version (or a different plugin altogether) would be a Good Thing, and probably of more use to more people. Probably beyond my (minimal) coding skills, but I’ll check up on your suggestions when I have more time next week. Thanks for the comments.

  4. Pingback: Read a Random Blog Post

  5. niemi

    Excellent plugin :clap:

    One thing I would really appreciate though, would be a check box to enable “only show drafts from same category as viewed post”. Or just some basic instruction on how to modify the code in that way.

    Thanks anyway, and if you time to implement something like what I mention above, please email me.

    Good job :bow:

  6. Les Post author

    Thanks, niemi. My coding skills being as minimal as they are, I’m not at all sure how I’d do that :dizzy:

    If my brain starts working in the right direction, I’ll see if I can add some more features later.

  7. Les Post author

    Yes, this works just fine on WordPress 2.5, or at least didn’t break on my test site.

    The options page doesn’t look quite as “2.5” as it might, but it all appears to work just fine. I’ll aim to update the version on the Plugins Directory soon.

  8. Les Post author

    Yes, it’s working for me on 2.5.1, and it’s simple enough that it should work with future versions, unless some very major changes are made to WordPress.

    When I get a chance, I’ll update it to look a bit more like the 2.5.x admin interface.

  9. Marc

    Excellent Plugin, but please: Never use this short_open_tags. Some people have deactivated this bullshit in their php config, because writing “<?xml …” will throw an fatal php error.
    e.g.: in the options page … with short_open_tags = off this is not parsed by php. Simply write and it will work with every configuration.


  10. freedimensional

    Hi Les,

    I installed your plugin above all others because it is the most customisable code in the repository. Well done! What I’d like to suggest for your next version is to use the widget as a persuasion tool to get readers to subscribe via RSS.

    It would be nice to add the option ‘RSS Address’ so the output in the sidebar says:
    “Subscribe via RSS to read these upcoming posts first: [followed by posts]”.

    If you don’t have the time, I would be happy to create a fork of the plugin and give you full credit, though of course it is your call.

    Let me know,

  11. David Artiss

    Great plugin – just what I was looking for.

    Any chance that you could add an option to alter the order of the results? I’d like it in descending creation order, for instance, with the latest draft posts at the top. Meantime, I can simply change the SQL line in the plugin to achieve this, but it would be a nice option to have for future.


    1. Les Post author

      Thanks – it’s been quite a while since I did any work on this at all, and I’d have to remind myself how to make any useful changes. I’ll think about a revised version when I have more time (and I’m not sure when that will be…)

  12. Pingback: Coming Soon – the Plugin : Losing it

Comments are closed.