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.

Delete Posts

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.

Leon

How To Change Your WordPress Admin Password via phpMyAdmin

If you’ve got a WordPress site, chances are you’ll get locked out of your admin at some stage whether it be a hacking issue or just plain forgetfulness. First step is to use the ‘forgot password’ function on the WordPress login screen but if you’re hacked or no longer using the email setup in WordPress – General settings then this won’t work.

The way I normally retrieve/reset passwords for myself or clients is to go into the hosting control panel’s phpMyAdmin section and do it manually in the database. Not for the faint-hearted I guess but not that hard when you’re walked through as I’m about to do!

Step 1:

Login to your hosting control panel at something like http://www.yourdomain.com/cpanel and click the phpMyAdmin icon under “Databases” as below:

phpMyAdmin

Step 2:

In phpMyAdmin, choose your WordPress database name top left then click on the “wp_users” table in the resulting table list to bring up a list of user accounts. There will probably be only one user for most people.

Step 3:

Click the “Edit” link on the user you want to change the password for.

Edit User

Step 4:

On the edit user screen, scroll to the “user_pass” row and type/paste in your new password then select “MD5” from the Function dropdown then “Go” at the bottom to save the new password in the database. This encrypts the new password.

Change WordPress Password

That’s it. You can now go back to the WordPress login screen and enter the new password and you should get in fine.

Leon