Select Wordpress posts by number of revisions


/ Published in: PHP
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.