所以我找不到任何东西,所以我创建了这个。唯一的缺点是,它会删除帖子中的“未分类”术语,但我可以接受,因为这只是为了发展。
function delete_all(){
global $wpdb;
$menus = get_terms( \'nav_menu\', array( \'hide_empty\' => false ) );
$all_post_types = get_post_types();
$all_taxonomies = get_taxonomies();
$all_options = wp_load_alloptions();
foreach ($all_options as $option) {
delete_option($option);
}
foreach ($menus as $menu => $menu_obj) {
wp_delete_nav_menu($menu_obj->term_id);
}
foreach ($all_post_types as $post_type => $post_type_value) {
$temp_posts = get_posts( array(\'post_type\' => $post_type, \'posts_per_page\' => -1));
foreach ($temp_posts as $temp_post => $temp_post_value) {
wp_delete_post($temp_post_value->ID);
}
}
remove_theme_mods();
foreach ( $all_taxonomies as $taxonomy ) {
// Prepare & excecute SQL - also deletes Uncategorized
$wpdb->get_results( $wpdb->prepare( "DELETE t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN (\'%s\')", $taxonomy ) );
}
}
add_action(\'wp_loaded\', \'delete_all\');
我在这里找到的分类部分:
http://wpsmith.net/2014/plugin-uninstall-delete-terms-taxonomies-wordpress-database/我看着wp_delete_term
, 但我不能让它工作。