Posted By

JoshChris on 04/07/16


Tagged

php wordpress revisions


Versions (?)

Select Wordpress posts by number of revisions


 / Published in: PHP
 

Too many revisions taking up space in your database? Use this script to find which posts have more than 10 - and then you can figure out what to do with them.

  1. $query = "SELECT COUNT(*), `ID`, `post_title`, `post_content`, `post_parent`, `post_modified`, `post_name` FROM $wpdb->posts WHERE `post_type` = 'revision' AND DATE(`post_modified`) < DATE_SUB(CURDATE(), INTERVAL 30 DAY) GROUP BY `post_parent` HAVING COUNT(*) > 10 ORDER BY COUNT(*) DESC LIMIT 10";

Report this snippet  

You need to login to post a comment.