我没有测试这个,但应该可以:
function check_post_attachments($post_id, $post){
if(empty(get_posts(array(\'post_type\' => \'attachment\', \'post_parent\' => $post_id)))){
$post[\'post_status\'] = \'draft\';
wp_update_post($post);
}
}
add_action(\'save_post\', \'check_post_attachments\');