How to set up a real cron job in WordPress?
WordPress real cron job refers to a method of scheduling and executing tasks, such as updating plugins, sending email notifications, or performing other automated actions, within a WordPress website.
| Using Cronjob
|| Via Cpanel
Navigate to the wp-config.php file, which is located in the root of the folder where WordPress is installed.
Once you open the wp-config.php file, insert a new line after define('WP_DEBUG', false);.
Add the following code on the new line and save the changes:
📝 Note: If you are not sure how to navigate to this file via your Cpanel or FTP, you can install this plugin, which will allow you to edit the files on your server directly from within WordPress.
Navigate to the File Manager panel.
Right-click on the wp-config.php file and click on Edit Code.
Search for the definer('WP_DEBUG', false); line and add the following line:
Click on Save & Close.
Once you have turned off the default WP Cron, the plugin that uses it (in our example, Feedzy RSS Feeds) will generate a warning notice:
Go to https://console.cron-job.org/signup, create an account, and log into the website.
Open the Cronjobs panel and click on Create Cronjob.
Fill out the details of the Cronjob.
For Title, enter anything you wish; for URL, enter your website domain suffixed with /wp-cron.php?doing_wp_cron.
- Change yourwebsitedomain.com to your actual website domain
- If your website does not have SSL, then change https to http
Finally, set the Execution schedule to suit your needs.
You can use the Test Run button at the bottom of the page to see if it works:
The other method to fix the issue is creating a true cron for your website. This requires you to have access to your cPanel account to make the following changes.
📝 Note: HostGator has gone ahead and created a pretty detailed document on how to create a true cron for WordPress, so we will use it. Please go here to view the document: How to create a true cron for WordPress. The screenshots from the article refer to HostGator, so the interface might be different according to the hosting provider.
If you are not comfortable with performing any of these methods, then we highly recommend you contact your web host for assistance. They will be able to perform either method for you in no time.
If you are having trouble implementing this method, then please forward this document to your Web host support personnel. They will be able to implement the true cron for you. A recommended interval for the cron job would be once every 10 minutes.