it’s one from Door To Online In this tutorial, I’m going to show you how to speed up your WordPress site. if your site has high traffic so what I’m talking about specifically is the Wp-cron.php file.
Now, this file loads every time someone visits your site and it checks whether there is a scheduled action to be done then it does that action so the most common use of this is scheduled posts .if you schedule any posts in advance. if you say you schedule it for tomorrow morning at 8 a.m. that will only publish when someone visits your website so even though you have it scheduled for 8 a.m. if nobody actually visits your website until noon that won’t publish until noon tomorrow. like I said every time someone visits your site this cron file runs and checks for scheduled action. You have a really high traffic site that can really slow you down and if your host is on top of their game they will actually contact you and tell you that you got to fix your cron before they start messing up the shared hosting as well because if you’re on shared hosting you’re going to have other sites that are affected by the stillness of your site or sorry by the number by the amount of server resources your site is using.
Below 4 Step shown disabling and setting System up Cron
So an easy thing we can do is we turn off Wp-cron.php and we create a cron on the server side now there are two benefits of this one is you won’t miss a schedule so when we schedule it on the server side Wp-cron.php will run exactly when we tell it to it’s not going to rely on people visiting your site to run it’s going to run when we tell it to and it’s only going to run when we tell it to .so that means that it’s not going to run every single time someone visits your site so normally I set this to run every 6 hours.now
That’s a pretty good timeframe you can set to whatever you like you can set it to every week every day every six hours every hour. If your site publishes a lot of stuff if you can start going faster than that you start using a lot of server resources again so the point of this is to reduce the number of server resources you use which will make your site faster so the first thing we have to do is disabled the Wp-cron.php right now in my cPanel account.
I’m just going to log into the file manager you can do this via FTP or SSH you just have to get access to your WP config file or WEP – config file. we’re going to open it in the editor. I’m a piece of code we’re going to paste right down below this last database entry .it’s going to copy from here and this code is also found down below in the description below. This video so what this is saying is the function disabled Wp-cron so that’s true so we’re going to say yes to disabling .
Wp-cron when we save this if you have any scheduled posts that are scheduled to run they will now not run because you have disabled the cron so we need to re-enable it on the server-side. We’re going to do that by going back to our cPanel. we’re going to find a place called cron jobs. It’s going to search for it here we have cron jobs. We’re going to open that and this is where we can set our cron jobs and it’s quite easy because all you have to do is copy and paste the code that I have down below.
We can easily tell WordPress to let us handle the execution of wp-cron.php with the wp-config.php file.
- Open your wp-config.php file with the cPanel File Manager Code Editor
- Go to the bottom of the database settings in wp-config.php typically around line 37. Add the code: define(‘DISABLE_WP_CRON’, ‘true’);
- Click Save
which is the same as this code here put it into the command line assuming that you WP – cron.php file lives in the public underscore HTML folder the only thing you’re gonna have to change is the username so this is the path to this file and we can confirm that it’s the right path. I’m just going to go back out of here go back to the file manager so it’s going to confirm that we have the right path and then we have the right username so public underscores HTML folder.
we have all our site files and right here there’s a WP cron so that is the right path public underscore HTML is the last folder we need to go into and my username is found right after the home so /home forward-slash this is my username WP Ph.D. now your username will probably different fact it guaranteed will be different but you’ll find it right here inside of your file manager so we closed this again we can go back to our cron jobs now that we’ve verified we have the right information we’re going to copy and paste this again so we’re telling the server to change directory to this folder we’re going to run a PHP file and the PHP file is WP dash grande PHP now we’re going to now set the schedule that you want to run on so what I usually do is.
- Log into cPanel
- Click on cron jobs Under the Advanced section, click on Cron Jobs.
- Select Once an hour from the Common Settings drop-down.
- Now select Every 12 hours from the Hour drop-down.
- Finally fill in the code to run the cron job and click Add New Cron Job – code: “cd /home/username/public_html; php -q wp-cron.php” (Where username is your cPanel user name.)
I have it at zero for the minutes every six hours for the time every day for the day every month for the month and every day for the weekday now this should run seven days a week just going to click on add cron job and now we have the cron job down here it’s going to run on on the hour every six hours every day every month every weekday which is seven days a week and now you don’t have to worry about your cron jobs a slowing down your site you don’t have to worry about them not firing properly even if you have a low traffic website and you find that you’re missing scheduled posts this is a way to fix that you will not miss a scheduled post this way because the cron will fire every six hours and it’s going to make sure your posts are scheduled and posted.