How can I delete old posts in WP?

bennyb

Regular Member
Joined
Feb 8, 2009
Messages
312
Reaction score
94
Good day folks.

I run three autoblogs and I am at the point where I have only 20% left available out of 40gb space. My databases are over 1 gig combined and each blog has 100.000+ posts. I want to purge some old posts but don't know any plugins or sql queries to do it. And I definately can't do it manually.

Is there any plugins that would allow me to delete posts made before certain date?
 
you can try the following:

Code:
<?php
include('wp-blog-header.php');

global $wpdb;

$posts = $wpdb->get_results("SELECT id from $wpdb->posts WHERE post_date < 'YYYY-MM-DD'");

foreach ($posts as $post){
     wp_delete_post($post->id);
}
?>

you might also want to include a LIMIT in the query if you have more than a few thousand posts
 
Back
Top