How to get wordpress cron job function working?
-
I m working to randomize all the posts every day (as the date changes) by itself, and I have created a function that shuffles and returns the random post ids which I can use to show random posts.
Anyways, all I want is to schedule this function to execute everyday at 12:00.
I used WordPress function wp_schedule_event(); however that doesn’t seem to work. Has anyone worked on it before ? and know how to make it work? This is a test code I have used, m I doing something wrong?add_filter('cron_schedules', 'my_additional_schedules'); function my_additional_schedules($schedules) { // interval in seconds just to test if it is working $schedules['every2min'] = array('interval' => 2*60, 'display' => 'Every two minutes'); return $schedules; } // schedules the wp_cron_testing if( !wp_next_scheduled( 'wp_cron_testing' ) ) { wp_schedule_event( time(), 'every2min', 'wp_cron_testing' ); } add_action( 'wp_cron_testing', 'the_wp_cron_test' ); function the_wp_cron_test() { echo "Here I have my code that needs to execute."; }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to get wordpress cron job function working?’ is closed to new replies.