iCalendar Importer/Exporter - Change Sync Time

By default, iCalendar Importer/Exporter auto-refreshes every hour, using a WordPress cron event. WordPress offers natively 3 recurrences:

  • hourly
  • twicedaily
  • daily

So if you need a custom interval, you need to register your custom cron schedule first. Let's say you want to create a custom interval that runs the cron every 15 minutes. The first step is register this new schedule.

In your functions.php file (of your child theme or theme):

function hotelier_custom_cron_schedule( $schedules ) {
    $schedules[ '15min' ] = array(
        'interval' => 15 * 60,
        'display'  => esc_html__( 'Every 15 minutes', 'your-text-domain' ),
    );

    return $schedules;
} 
add_filter( 'cron_schedules', 'hotelier_custom_cron_schedule' );

Then you can use the 'hotelier_icalendar_sync_interval' filter to change the default iCalendar Importer/Exporter cron job:

function hotelier_custom_sync_interval( $sync_interval ) {
    return '15min';
} 
add_filter( 'hotelier_icalendar_sync_interval', 'hotelier_custom_sync_interval' );

Alternatively, you can use the WP Control plugin.

Please remember that WordPress crons are not real cron jobs. They are executed every time someone loads a page. To replace WordPress crons with a real cron job follow this tutorial.