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?
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?
You must be logged in to post a comment.
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 forpost_excerpt
(likeif ( 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 theredirect_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.