I was wondering if someone of you guys have implemented such a script in PHP or mysql that runs though a cronjob.
I want to delete every post that is made within the last days with a simple command. I was wondering if
DELETE FROM wp_posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 30 DAY);
gonna work there. What do you suggest?
Your one line of MySQL isn't enough. To fully remove a post, you need to also delete the following:
wp_postmeta
tablewp_comments
tablewp_commentmeta
table for those commentsIn terms of providing an actual solution, the following plugins do what you need:
Also, if you are simply trying to keep your database tidy you can add this line of code to your wp-config.php
file define( 'WP_POST_REVISIONS', 8 );
This stops WordPress from creating infinite numbers of post revisions in the database. Not your stated problem but handy.