1

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?

2

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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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