【问题标题】:I want to set wp_schedule_event specific time我想设置 wp_schedule_event 具体时间
【发布时间】:2014-07-21 22:57:57
【问题描述】:

我每天早上 00:01 设置 wp_schedule_event。我的代码在这里:

<?php

    add_action( 'wp', 'cron_hookup' );
    /**
     * On an early action hook, check if the hook is scheduled - if not, schedule it.
     */
    function cron_hookup() {
        if ( ! wp_next_scheduled( 'cron_funct' ) ) {
            wp_schedule_event( time(), 'hourly', 'cron_funct');
        }
    }

    add_action( 'cron_funct', 'cron_order' );

 ?>

【问题讨论】:

    标签: php wordpress cron


    【解决方案1】:

    您似乎去过Codex 来获取您的代码,但那里可能还不够清楚。所以我会看看我能做些什么。

    add_action( 'wp', 'cron_hookup' );
    function cron_hookup() {
        if ( ! wp_next_scheduled( 'prefix_hourly_event' ) ) {
            wp_schedule_event( time(), 'daily', 'cron_funct');
        }
    }
    /** This code will setup the cron job to run daily */
    
    
    add_action( 'cron_funct', 'prefix_do_this_daily' );
    function prefix_do_this_daily() {
        // This is the code that will be done executed every day.
    }
    

    另外,http://wordpress.stackexchange.com 可能更适合回答此类问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-09
      • 2013-01-25
      • 2019-04-09
      • 2013-11-14
      • 1970-01-01
      • 2017-01-19
      相关资源
      最近更新 更多