When managing your WordPress site, you might notice that URLs occasionally include the ?doing_wp_cron
query string. This is not a cause for concern, but rather an indicator that a specific configuration is active in your WordPress installation.
What is ?doing_wp_cron?
The ?doing_wp_cron
string appears in URLs when WordPress is executing background tasks, such as publishing scheduled posts or handling backup routines. It is added when the ALTERNATE_WP_CRON
constant is defined in your wp-config.php file, prompting WordPress to perform certain tasks by redirecting users to the relevant page with this query appended.
Why Does This Happen?
This behavior is usually triggered by:
Backup plugins like UpdraftPlus or All-In-One WP Migration
Scheduled post publishing
Other tasks that rely on WordPress Cron Jobs
Since WordPress uses virtual cron jobs to perform scheduled tasks, it needs to load a page occasionally to initiate the background process.
How to Disable ?doing_wp_cron in Your WordPress URLs
There are a couple of ways you can prevent this string from appearing in your URLs:
1. Modify Your wp-config.php File
If you don't want WordPress to use the alternate cron method, follow these steps:
Access your site’s files through FTP or your hosting File Manager.
Open the wp-config.php file in the root directory of your WordPress installation.
Find the line containing:
define('ALTERNATE_WP_CRON', true);
Delete this line to disable the alternate cron job method.
Note: Removing this line might cause scheduled tasks to stop working if no other cron jobs are set up. Ensure you have another cron mechanism in place.
2. Use .htaccess to Hide ?doing_wp_cron in URLs
Another way to prevent the query string from appearing in your URLs is by adding a rule to your .htaccess file. Follow these steps:
Open your site’s .htaccess file, usually found in the root directory.
Add the following code snippet to redirect any URL with
?doing_wp_cron
:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)doing_wp_cron= [NC]
RewriteRule (.*) /$1? [R=301,L]
</IfModule>
Save the file and refresh your site to confirm the change.
This will ensure that the ?doing_wp_cron
parameter is hidden from users while the tasks still execute in the background.
3. Use a Server-Side Cron Job
If your hosting provider supports server-side cron jobs, you can set one up to handle WordPress tasks and disable the alternate cron method in the wp-config.php file.
Access your hosting control panel and locate the Cron Jobs section.
Add a new cron job to run the following command at regular intervals:
wget -q -O - https://yourwebsite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
Disable the alternate cron method by removing or commenting out the
ALTERNATE_WP_CRON
line in your wp-config.php file.
This method ensures that your tasks run efficiently without relying on user visits.
The presence of ?doing_wp_cron
in your URLs is a standard part of how WordPress manages background processes. If you want to hide it, you can either disable the alternate cron method in your wp-config.php
or manage redirections via your .htaccess file. For more robust solutions, consider setting up server-side cron jobs to ensure seamless background task execution.
Still need help?
Contact us