Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

php - wp_schedule_event not firing

I'm trying to schedule an event inside a theme's functions.php but I cannot get it to "fire". I'm using the Cron View plugin and it shows the event scheduled correctly but nothing happened when is time to execute.

This is my code

if ( ! wp_next_scheduled( 'prefix_hourly_event' ) ) {
    wp_schedule_event( time(), 'hourly', 'prefixhourlyevent');       
}
add_action( 'prefixhourlyevent', 'prefix_do_this_hourly' );

function prefix_do_this_hourly() {                
    wp_mail('[email protected]','Cron is working', 'Cron is working: ','','');
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can manually run WordPress cron jobs by going to http://www.example.com/wp-cron.php?doing_cron. This is where you will be able to see any errors that your scripts creates, really useful when debugging wp scheduled tasks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...