你想写一个wp_insert_post_empty_content 滤器
WordPress已经try and reject empty posts:
$maybe_empty = \'attachment\' !== $post_type
&& ! $post_content && ! $post_title && ! $post_excerpt
&& post_type_supports( $post_type, \'editor\' )
&& post_type_supports( $post_type, \'title\' )
&& post_type_supports( $post_type, \'excerpt\' );
但我想你在这里没有领会到这种逻辑。因此,你需要找出你的空帖子是什么样的,并抓住它们:
function wpse390344_empty_posts_filter( $empty, $postarr ) {
if ( ! $empty ) {
// TODO: look at $postarr - see wp_insert_post() documentation for format
// and decide if this is an empty post you want to reject.
// If it is, return true.
}
return $empty;
}
add_filter( \'wp_insert_post_empty_content\', \'wpse390344_empty_posts_filter\', 10, 2 );