你可以加入before_delete_post
和redirect before completing the deletion.
add_action(\'before_delete_post\', function($post_id) {
// Get custom field
$field = get_post_meta( $post_id, \'key\', \'true\');
// Redirect if field is empty
if (!$field) {
wp_redirect(admin_url(\'edit.php\'));
exit();
}
}, 1);