this is my code

function myprefix_custom_cron_schedule( $schedules ) {      
        $schedules['every_day'] = array(
            'interval' => 86400, // Every 24 hours
            'display'  => __( 'Every 24 hours' ),
        return $schedules;
    add_filter( 'cron_schedules', 'myprefix_custom_cron_schedule' );

    //Schedule an action if it's not already scheduled

        if ( ! wp_next_scheduled( 'myprefix_cron_hook' )) {
                wp_schedule_event( time(), 'every_day', 'myprefix_cron_hook' );

    ///Hook into that action that'll fire every 24 hours
     add_action( 'myprefix_cron_hook', 'get_products_url' );

the codes above fires an event every 86400 seconds(24hr), but from first time it was fired...
I want my event fires every night at 23:00
How can I set the specific time for firing the event?
Please help me... thanks

  • 2
    You do know that this is triggered by visits? So you can't be absolutely sure it will fire the specific time you want. If you are ok with this check wp_schedule_event( strtotime('23:00:00'), 'daily', 'myprefix_cron_hook' ); Sep 28, 2017 at 13:52

1 Answer 1


The internal WordPress cron is dependent upon site visitors to fire, unlike linux or unix cron which is fired at specific times. Generally speaking, if you have regular and frequent visitors to your website WordPress cron will run your defined task. But if you don't have that traffic WordPress doesn't fire the events.

If your hosting environment is linux/unix based and you have appropriate access you can call the WordPress cron consistently and at specified times via the system or user cron tasks.

A Google search on "using cron to run wordpress cron" will return a number of FAQs and step by step instructions for setting this up. Your own hosting provider may even have complete instructions.

A fairly good example can be found at HostGater.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.