List Drafts Widget

Updated, March 2010: Advance warning: I’ve finally got round to redoing this widget using the Widget API introduced in WordPress 2.8. Thought I’d better do it before a WordPress update breaks it. There will be an update here and probably a new post when the new version is available.

A long time ago[1], I unleashed on the world my first (and so far only) WordPress plugin: List Draft Posts. It’s a simple thing that lists the titles of any posts that you’ve started on but not yet posted. Simple is the only kind of coding I can generally manage, so it’s stayed simple, the only bit of sophistication being a form to control the layout it uses[2]. But it works for me, and it’s possible that one or two of the 239 people who’ve downloaded it from the WordPress plugin repository might be using it[3].

But it did lack one thing: it couldn’t be used as a WordPress widget. Well, there are ways of using a special widget to run a plugin’s function, but that’s not the same thing, is it? Having started to move my site to widgets, I decided to learn how to turn my own simple plugin into a widget, and started searching.

And that was a bit tricky at first. Some documentation I found assumed rather too much in the way of coding knowledge, and missed out some details that would be needed if you actually wanted your widget to work. But after a while, I found a post by Kaf: My Widget – example WordPress Widget. This, together with some changes suggested in the comments enabled me to get to work. After a lot of fiddling, tweaking, head-scratching, editing, re-editing and muttering, I managed to create a new version of List Draft Posts that is entirely widgety. Someone who knows how to code could probably make a version that would work as either a plugin or a widget, but for now I’m going to leave it as two separate versions.

As a standard widget, it doesn’t need much configuration – you can enter a heading to go above the list of posts, and a description for any draft posts that don’t have titles. It outputs its stuff in an unordered list below the heading:

<li>A post I need to finish</li>
<li>Another post I've started</li>

I’m going to play with it a bit more, make sure it doesn’t break anything, then submit it to the repository. If anyone desperately wants it before then, leave a comment, and I’ll make it available by some means or other.

Update: You can now get the widget from the official repository: List Drafts Widget

[1] In internet time
[2] And that lacks a lot of sophistication itself
[3] Hi guys :wave:

8 thoughts on “List Drafts Widget

  1. AlanGalangalan@gmail

    Hey, I’m about to add the PHP for List Draft Posts on my sidebar, but it would be nice to have the widget you mentioned. Have you released it yet? I think I’d be willing to install it on my site if it seems to work for you. Thx.

  2. Pingback:

  3. Maître Mô

    Hi Less,

    And thank you for your plugin, very “simple” and usefull !
    I just wonder if it’s possible to put in the darft posts list the name of the author of the post, like this for example :
    “Postx (Mô)
    Post y (Marie)”
    … And so on ?
    Thank you very much if you know, and… Thank you in any case (sorry for my english, I’m french… As you obviously see !)

  4. Pingback: Använda wordpress som ehandelslösning för webshop | ehandel, ledarskap, affärer och realtids media

Comments are closed.