Aradığım bu ama bunu nasıl eklicem
functions.php dosyasına şu kodları ekleyeceksiniz. 30 günden eski postları siliyor (muş)
/**
* Add monthly interval to the schedules (since WP doesnt provide it from the start)
*/
add_filter('cron_schedules','cron_add_monthly');
function cron_add_monthly($schedules) {
$schedules['monthly'] = array(
'interval' => 2419200,
'display' => __( 'Once per month' )
);
return $schedules;
}
/**
* Add the scheduling if it doesnt already exist
*/
add_action('wp','setup_schedule');
function setup_schedule() {
if (!wp_next_scheduled('monthly_pruning') ) {
wp_schedule_event( time(), 'monthly', 'monthly_pruning');
}
}
/**
* Add the function that takes care of removing all rows with post_type=post that are older than 30 days
*/
add_action( 'monthly_pruning', 'remove_old_posts' );
function remove_old_posts() {
global $wpdb;
$wpdb->query($wpdb->prepare("DELETE FROM wp_posts WHERE post_type='post' AND post_date < DATE_SUB(NOW(), INTERVAL 30 DAY);"));
}