0

Open the wp-cron.php page into the browser, eg. opening this url http://example.com/wp-cron.php?doing_wp_cron run the cronjob or WordPress block request made by browser?

1
  • 1
    It will run any cron jobs that are scheduled to run. It's a common practice to create a real cron job on the server that hits this URL, if that's what you're looking to do. – Jacob Peattie Oct 11 '19 at 0:36
-1

You'd be better off using the wordpress API:

function wp_register_cron_endpoint() {
  register_rest_route( 'crons', '/run_cron', array(
      'methods' => 'GET',
      'callback' =>  'run_crons'
  )); 
}

add_action( 'rest_api_init', 'wp_register_cron_endpoint' );

function run_crons(){
  /*** Do whatever you want ***/
}

Then you can hit http://example.com/crons/run_crons and you'll A)Trigger wp_cron based on the wp_load and B) Do whatever you want in the function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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