I am trying to create a cron job to run on my server which deletes a custom post_type (post_type = event) from my databse based on a meta_key (st_date) and a meta_value (the date the event took place ie. 2013-04-30).
I want it to automatically delete any event that took place over 30 days ago from the current date. I have been unsuccessful so far, with trying to use the DATEDIFF() > 30 function. My issues so far have been with creating the mysql query to delete the events.
DELETE FROM 'wp_posts', WHERE 'post_type' = 'event' INNER JOIN 'wp_postmeta' ON 'wp_post.post_id' = 'wp_postmeta.post_id' AND 'meta_key'='st_date' AND 'meta_value'= '(DATEDIFF(NOW()) > 30)'
Any help would be appreciated.