Muhatrima
Power Member
- Dec 20, 2020
- 778
- 490
I have been searching for a way to delete all Wordpress posts including their media attachments after x days.
I have seen a couple plugins but they have either not being updated lately or are very new and not good for security reasons.
However I have found this code, Which is a cron that has to be run
I am not sure, how to run this cron job on wordpress installation, so can anyone help either with how to run this cron or any other code that can be put into WordPress theme functions.php ?
I have seen a couple plugins but they have either not being updated lately or are very new and not good for security reasons.
However I have found this code, Which is a cron that has to be run
Code:
DELETE FROM `wp_posts`
WHERE `post_type` = 'post'
AND DATEDIFF(NOW(), `post_date`) > 30
I am not sure, how to run this cron job on wordpress installation, so can anyone help either with how to run this cron or any other code that can be put into WordPress theme functions.php ?