Skip to: site navigation/presentation
Skip to: Thoughts From Eric

Wanted: Excerpt Exacter

So after I once again published a post without filling in the excerpt, thus forcing me to go back to fill it in later, I tweeted in a fit of pique:

I need a WordPress plugin that won’t let me publish a post until I’ve filled in the excerpt field. Anyone got one?

To which I got a whole lot of responses saying, in effect, “Oooo!  Good idea!  I need that too!  Let me know when you find one!”  Some of them came from people running fairly high-profile blogs.  The need clearly exists.  A couple of responses were of the “I could do that!” variety, so I thought I’d post here so as to describe how I think it ought to work from the user’s perspective, and then we can hash things out in comments and someone can code it up and make everyone happy.

So really what I want is, when I push the “Publish” button in WordPress, the plugin checks to see if there’s an excerpt.  If not, one of two things happens:

  1. The plugin throws up a warning dialog telling me that I’m about to post without an excerpt (again).  If I say “Okay”, it goes ahead with publishing.  If I say “Cancel”, it returns me right back to where I was, which is the “Write Post” page, with all the data intact and unaltered.

  2. The plugin returns me to the “Write Post” page with all data intact and unaltered, and puts an error box at the top of the page telling me I forgot to write an excerpt (again) and that it won’t let me publish until I fix the problem.

One or the other.  I think I like #1 a little better, but I’d be good either way.  I’m open to other approaches as well, but I don’t think the plugin should rely on JavaScript, as that means leaving out people who don’t enable JavaScript or post from JS-incapable devices.

I would do this myself, but I’m a little wary of the “return to the page with all data intact and unaltered” bit, which I would imagine is pretty easy to mess up.  Thus I’m putting it up here as a semi-Lazyweb post so that someone else, someone with more experience with WordPress and plugin authoring, can do it right and quickly.

Okay, who’s on it?

19 Responses»

    • #1
    • Comment
    • Tue 10 Jun 2008
    • 2227
    Shelly wrote in to say...

    Ooo…I think that could be done. #1 would definitely be easier than #2.

    I do love a challenge though :)

    • #2
    • Comment
    • Tue 10 Jun 2008
    • 2230
    Hamish M wrote in to say...

    I’m on it. Nothing like a small plugin challenge to keep the mind energized.

    Will report back when I have a working prototype. Shouldn’t be too long. :)

    • #3
    • Comment
    • Tue 10 Jun 2008
    • 2237
    Will Kessel wrote in to say...

    Eric, I can hand this off to a guy at work — and willingly so because Jim (our fearless leader) wants every post to have an excerpt before it gets posted. I’d jump on it myself except I’m pretty jammed up right now.

    As I twitted back to you this afternoon, I’d have it check (on-click) to see if you had included an excerpt. If not, the best way to return you to the editing page would be to first save the post as a Draft and take you back to the post edit page. Else, you could publish it anyway.

    You could build into the admin page an option for the “post anyway” or “never post without” choice and therefore have it both ways.

    It would be a simple test to look for the presence of the_excerpt() and run from there.

    Personally, I’d make it look cool by using a jQuery lightbox-style dialog box with one of the pre-installed jQuery plugins in the WP Admin area, but that’s just me playing with the eye candy… ;-)

    • #4
    • Pingback
    • Tue 10 Jun 2008
    • 2323
    • #5
    • Comment
    • Tue 10 Jun 2008
    • 2330
    Erik wrote in to say...

    WP 2.5 admin uses jquery right? I bet you could just insert a little script that gives you a confirmation box if the excerpt field is empty.

    • #6
    • Comment
    • Wed 11 Jun 2008
    • 0056
    Hamish M wrote in to say...

    Okay. Version 1.0 is ready.

    Some notes
    So yeah, it’s called Never Forgetcerpt, haha, maybe a little lame but hey, who cares. It works as far as I can tell, only tested in WordPress 2.5, and it uses jQuery, so with older WP installs probably won’t work so well, i.e. at all. See the readme.txt for more info.

    *glances at footer* — Whoah, Eric, are you really using WP 1.5? Hmm, probably isn’t going to work for you. You gotta upgrade man!

    Anyway, it’s GNU licensed, anyone feel free to take it and do what you like with it. I hope it’s useful to some.


    • #7
    • Comment
    • Wed 11 Jun 2008
    • 0114
    Alexander Maltsev wrote in to say...

    I use this “hack”, use it in loop:
    <?php if ( ($post->post_excerpt != '') && (!is_single()) ) {the_excerpt(); }
    else the_content('Прочтём до конца?',strip_teaser);?>

    • #8
    • Comment
    • Wed 11 Jun 2008
    • 0333
    Travis wrote in to say...

    wow, the plug-in is already available even before I get to leave a comment… Good job Hamish!

    • #9
    • Comment
    • Wed 11 Jun 2008
    • 0343
    AlastairC wrote in to say...

    I have a related problem: The automated excerpt would be fine, if it included pictures, and included the first paragraph rather than first X characters.

    90% of the time the above approach would be what I intended, the other 10% would still be closer, but I would edit it slightly.

    • #10
    • Comment
    • Wed 11 Jun 2008
    • 0344
    AlastairC wrote in to say...

    “Whoah, Eric, are you really using WP 1.5?”

    The source says it’s the latest, so I’d assume the footer is just content.

    • #11
    • Comment
    • Wed 11 Jun 2008
    • 0458
    Eric Meyer wrote in to say...

    Very cool, Hamish! Thank you! There’s one thing about it that worries me, which is that it doesn’t save anything. So if I accidentally close my browser window because I see a little pop-up I want to dismiss and my muscle memory kicks out a command-W, I’ll lose whatever changes I made right before hitting “Publish”. 95% of the time, that won’t happen, but the other 5% will be really annoying. Is there any way to modify things so that a save-draft operation is fired right before putting up the warning box?

    Oh, and I’m on the latest version; I just hadn’t updated my footer. Thanks for reminding me to get it fixed.

    • #12
    • Comment
    • Wed 11 Jun 2008
    • 0838
    Adam Rice wrote in to say...

    This seems to be solved already, but Ecto (not a plugin) also optionally gives warnings if you try to post without an excerpt, category, and/or (maybe?) tags.

    • #13
    • Comment
    • Wed 11 Jun 2008
    • 1023
    Hamish M wrote in to say...

    Hey, thanks a lot Eric! I’m glad you like it.

    I’ve now updated the plugin to autosave when you click either Save or Publish. Same address:

    Also, I’m glad to hear you’re not actually using WordPress 1.5. You had me worried there for a minute!

    • #14
    • Comment
    • Wed 11 Jun 2008
    • 1034
    Eric Meyer wrote in to say...

    So awesome, Hamish. You rock.

    Now, what do you think of extending your excellent work into a more complex plugin called (for example) “Forget-Meta-Not” which lets the user set preferences to warn them if they’ve forgotten any of excerpt, categories, or tags? (Inspired by both my further thinking and Adam mentioning what Ecto does.)

    • #15
    • Comment
    • Wed 11 Jun 2008
    • 1125
    Hamish M wrote in to say...

    Great idea. I know I’ve forgotten categories, tags, etc. before as well, so that would be quite useful.

    I’ll see what I can do.

    • #16
    • Pingback
    • Thu 12 Jun 2008
    • 2052
    Received from NeverForgetcerpt Plugin :: WPLover

    […] begins from CSS godfather Eric Meyer’s tweet a few days ago, which then turns into a blog post: NeverForgetcerpt, a plugin that will warn you if you’re posting an article without creating […]

    • #17
    • Pingback
    • Tue 17 Feb 2009
    • 0837
    Received from The manual Excerpt in WordPress. What, why, how, tips and plugins -

    […] Wanted: Excerpt Exacter […]

    • #18
    • Comment
    • Fri 27 Mar 2009
    • 0812
    Doug Barned wrote in to say...

    Hi there :)

    Sounds like just what I need! however, the link is dead… can anyone please point me in the direction of this plugin?



    • #19
    • Pingback
    • Tue 23 Oct 2012
    • 1528
    Received from WordPress plugin: Admin Anti-forget Alarm » Tiago Madeira

    […] to fix some stuff before publishing something, and it looks like this is a useful feature for other people as well. There is even a Require Thumbnail plugin in the WordPress Plugin Directory that seems to […]

Leave a Comment

Line and paragraph breaks automatic, e-mail address required but never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Remember to encode character entities if you're posting markup examples! Management reserves the right to edit or remove any comment—especially those that are abusive, irrelevant to the topic at hand, or made by anonymous posters—although honestly, most edits are a matter of fixing mangled markup. Thus the note about encoding your entities. If you're satisfied with what you've written, then go ahead...

June 2008
May July