Prevent saving empty posts
-
Hi,
I noticed that it is possible to save empty posts (no title, content and excerpt). I think this is very strange. I tested it on various sites to see if I’m right and I believe I am.
How can I prevent this? I don’t want this behaviour, especially with custom post types.
In post.php I found the following part:
if ( apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $postarr ) ) { if ( $wp_error ) { return new WP_Error( 'empty_content', __( 'Content, title, and excerpt are empty.' ) ); } else { return 0; } }
I would expect this to throw an error but I guess I’m wrong.
So next I tried this filter, but that didn’t work:
//We do not want to be able to save posts without title and content: add_filter ('wp_insert_post_empty_content', function() { return false; });
So how can I prevent saving empty (custom) posts? Any suggestions?
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Prevent saving empty posts’ is closed to new replies.