Create a CRONJOB for Your WordPress WP-CRON

It’s 2023, we are able to generate text, images and web pages with AI, yet we are unable to disable wp-cron in our WordPress to make them faster and more efficient.

In my opinion, it’s a disgrace that this still exists. They could show an alert saying it has never run and provide configuration guides. (Although that’s not WordPress’s idea; it wants everything to be super user-friendly)

To manage internal tasks, WordPress uses users’ “visits”, which makes the user experience worse since, in most cases, it slows down the visit.

Disabling wp-cron in wp-config.php

The first thing we need to do is stop tasks from running on users’ visits, and this is done by editing our wp-config.php, which is in the root of our hosting, and adding the following code:

define('DISABLE_WP_CRON', true);

I’d recommend placing it below the database defines, so that all the additional content you add is in the same place.

Now we need to add the cronjob with this URL. I recommend running the cronjob every 2 or 5 minutes. (replace mywebsite.com with your domain)

wget -q -O /dev/null -t 1 "https://mywebsite.com/wp-cron.php?doing_wp_cron" >/dev/null 2>&1

This way, we’ll have a request to wp-cron every 2/5 minutes without affecting the user. In this way, we free the user from processing information that isn’t their job.