admin管理员组

文章数量:1289543

I'm trying to flush rewrite rule with a wp_schedule_event

function el_custom_cron_schedule( $schedules ) {
    $schedules['el_every_5mn'] = array(
        'interval' => 5*60,
        'display'  => __( 'Every 5 minutes' ),
    );
    return $schedules;
}
add_filter( 'cron_schedules', 'el_custom_cron_schedule' );

 // Flush permalinks every 5mn
function el_flush_permalinks_activation() {
    if ( !wp_next_scheduled( 'el_5mn_event' ) ) {
        wp_schedule_event(time(), 'el_every_5mn', 'el_5mn_event');
    }
}
add_action('el_5mn_event', 'el_flush_permalinks');

add_action('wp', 'el_flush_permalinks_activation');

function el_flush_permalinks() {
    flush_rewrite_rules(true);
}

So the Scheduled Task works, i test it with email sending (wp_mail in the function el_flush_permalinks)

The issue is that flush_rewrite_rules() is not launch. i thought it was the the hook wp but not.

Thanks for help

本文标签: permalinksFlush rewrite rules with scheduled event (cron)