I find-out an way, when working on a cron
related project.
1. Install and active [WP Crontol plugin][1]
2. Go to Tools->Cron Events.
3. Create new cron job at `Add PHP Cron Event tab. Here, I use PHP code
global $wpdb;
$posts_table = $wpdb->prefix . 'posts';
$term_relationships_table = $wpdb->prefix . 'term_relationships';
$postmeta_table = $wpdb->prefix . 'postmeta';
$sql = "DELETE a, b, c
FROM $posts_table a
LEFT JOIN $term_relationships_table b ON (a.ID = b.object_id)
LEFT JOIN $postmeta_table c ON (a.ID = c.post_id)
WHERE a.post_type="post"
AND DATEDIFF( NOW(), a.post_date) > 365
";
$wpdb->query( $wpdb->prepare($sql) );
now
and 12:00:00
in Next Run
Once Hourly
in Recurrence
- Save this cron event and click on run now.