只需使用自定义$wpdb
查询,类似
function remove_all_attachments() {
global $wpdb;
$ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = \'attachment\'");
if ( empty($ids) ) return;
$remove = implode(\',\', $ids);
// remove post meta
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ({$remove})");
// remove posts
$wpdb->query("DELETE FROM $wpdb->posts WHERE ID = IN ({$remove})");
}
那之后就打电话
remove_all_attachments()
不管你想要什么,你所有的附件都不见了,但文件还在那里。。。