Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to display a warning in the admin section when posting if the excerpt section hasn't been filled out to stop a post being published without an excerpt?

Does anyone know of a plugin that has this facility?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Writing your own plugin will help you understand WordPress better, subsequently enjoying it even more, beside you look like you are quite capable with some tiny bit of PHP, no?

When saving a post, the save_post hook is pulled on. This passes along the $post_ID and the $post variables, containing everything you need to check for post_excerpt (like if ( strlen( $post->post_excerpt ) < 10 ) ...).

If you want to explicitly do this only when a post is published you can hook to {$old_status}_to_{$new_status} hook.

To show a nice message or warning, tap into the post_updated_messages hook. You can alter the $_GET['message'] variable inside the redirect_post_location filter.

Alternatively, you can display the warning on the page at all times just by looking at the $post->post_excerpt property. Style it as an alert or use jQuery to remove the publish button altogether until the field is filled. Lots of options, depends on how far you're willing to take it.

share|improve this answer
    
I like the last option, the WP install I need this for is being used as a CMS with multiple users who always forget to fill in the excerpt, which is something that needs to be done as it's reflected on the auto updates on facebook etc... there is the option that it will autofill but that's sometimes too long. So I shall investigate the options you've talked about. –  Vince Pettit Mar 21 '12 at 12:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.