这个wp-crontrol 插件允许您添加新的cron事件以及新的cron计划。创建新事件时,需要提供要使用的动作挂钩的名称。我想最简单的方法就是在你的主题中设置一个钩子function.php 文件:
function update_meta_data($meta_id, $meta_value) {
global $wpdb;
$wpdb->update(
$wpdb->prefix . \'postmeta\',
array(\'meta_value\' => $meta_value),
array(\'meta_id\' => $meta_id),
array(\'%s\'),
array(\'%d\')
);
}
// Here we are setting up the action hook, notice that we also specify that the
// function takes two arguments.
add_action(\'cron_update_meta_data\', \'update_meta_data\', 10, 2);
然后使用
wp-crontrol 插件您可以为每个间隔创建单独的事件:
钩子名称-将是动作钩子的名称,例如cron_update_meta_data.参数(可选)-将设置为[65138, \'4 hours\'] 对于第一个事件下次跑步-第一场比赛将安排在周二上午9点定期-将此设置为每周运行一次同样值得注意的是wp-cron.php 只有当有人访问你的网站时才会执行,所以根据cron事件在指定时间实际运行的重要性,你可以设置一个真正的cron作业,然后执行wp-cron.php:
0 09 * * TUE curl http://example.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1