Delete WordPress Posts Older then (X) Days in PHPMyAdmin

I stumbled across this as a possible fix for slow loading and resource hogging websites that have LOTS of content, especially posts numbered in the thousands. Something like the Google spider could use up your sites bandwidth and resources pretty quick if it has to try index thousands of old posts. Most sites might not need to keep older posts live because they will have become irrelevant and outdated over time.

Login to your hosting control panel then click on the phpMyAdmin icon. Click the name of your sites database then “Export” on the top bar just to make a database backup first in case anything goes wrong. Choose “gzip backup” in advanced settings if your database is huge. Next click the “SQL” title on the top bar and paste the following in the box then click Go bottom right:

DELETE FROM `wp_posts`
WHERE `post_type` = 'post'
AND DATEDIFF(NOW(), `post_date`) > 180

What the above SQL command does is delete all blog posts in your site’s database with the posts type “Posts” as opposed to Pages and it deletes everything older than 180 days or 6 months. You can adjust this to suit yourself of course.

Once you’ve done this you might consider installing the Auto Prune Posts WordPress plugin to keep things tidy automatically in future.


Thank you for reading this blog and welcome back again! We are happy to see you here.  Did you like this post? Kindly share the post using the buttons below. Drop your comments below in the comment box. 

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

%d bloggers like this: