- Microlancer Beta Tester
- Author had a Free File of the Month
- Has been a member for 3-4 years
- Item was Featured
- Author was Featured
- Austria
- Exclusive Author
- Referred between 200 and 499 users
What is the best way to delete all post and pages (etc.) of a wordpress installation to restart with a “fresh” one? I truncate all tables this way but is there any “native” or recommended method?
TRUNCATE TABLE `wp_posts`; TRUNCATE TABLE `wp_postmeta`; TRUNCATE TABLE `wp_comments`; TRUNCATE TABLE `wp_commentmeta`; TRUNCATE TABLE `wp_links`; TRUNCATE TABLE `wp_terms`; TRUNCATE TABLE `wp_term_relationships`; TRUNCATE TABLE `wp_term_taxonomy`; DELETE FROM `wp_options` WHERE `wp_options`.`option_name` LIKE '_transient_%';
- Microlancer Beta Tester
- Author had a Free File of the Month
- Has been a member for 3-4 years
- Item was Featured
- Author was Featured
- Austria
- Exclusive Author
- Referred between 200 and 499 users
$removed = array();
if($wpdb->query("TRUNCATE TABLE $wpdb->posts")) $removed[] = 'Posts removed';
if($wpdb->query("TRUNCATE TABLE $wpdb->postmeta")) $removed[] = 'Postmeta removed';
if($wpdb->query("TRUNCATE TABLE $wpdb->comments")) $removed[] = 'Comments removed';
if($wpdb->query("TRUNCATE TABLE $wpdb->commentmeta")) $removed[] = 'Commentmeta removed';
if($wpdb->query("TRUNCATE TABLE $wpdb->links")) $removed[] = 'Links removed';
if($wpdb->query("TRUNCATE TABLE $wpdb->terms")) $removed[] = 'Terms removed';
if($wpdb->query("TRUNCATE TABLE $wpdb->term_relationships")) $removed[] = 'Term relationships removed';
if($wpdb->query("TRUNCATE TABLE $wpdb->term_taxonomy")) $removed[] = 'Term Taxonomy removed';
if($wpdb->query("DELETE FROM $wpdb->options WHERE `option_name` LIKE ('_transient_%')")) $removed[] = 'Transients removed';
$wpdb->query("OPTIMIZE TABLE $wpdb->options");
Any suggestions!?
well theres http://codex.wordpress.org/Function_Reference/wp_delete_post but it wouldn’t remove all the post just single by id.. is this a function you’re building or you trying to just making it easier for development?
also may want to look at http://wordpress.org/extend/plugins/wordpress-reset/
