Xem thêm

How to Fix WP-Cron Job Errors Caused By WordPress Hosting

Are you experiencing WP-Cron Job errors caused by your WordPress hosting? Don't worry, the solution is easier than you might think. By spending just five minutes resolving this issue, you can significantly improve the performance,...

Are you experiencing WP-Cron Job errors caused by your WordPress hosting? Don't worry, the solution is easier than you might think. By spending just five minutes resolving this issue, you can significantly improve the performance, usability, and search engine optimization of your WordPress website.

Identifying WP-Cron Job Errors

To identify if you have any WP-Cron Job errors, take a look at your website or the list of visited pages in your analytics software. Do you see URLs with "?doing_wp_cron=" followed by a string of numbers? For example, "http://www.example.com/article?doing_wp_cron=128337.128371298731298371923". If so, it indicates that you currently have an issue as those URLs are duplicates of existing articles.

Understanding WP-Cron Jobs and Their Failures

WordPress uses a file named "wp-cron.php" to schedule automated tasks such as checking for updates, sending emails, and backing up. This file acts as a virtual cron job triggered whenever a scheduled task is due to run. However, some WordPress hosts disable this functionality due to resource usage and security concerns.

Consequences of WP-Cron Errors

WP-Cron errors can lead to two main issues. Firstly, plugins and functionalities reliant on cron jobs may not work properly or generate errors. This includes scheduled posts, automated backups, and auto-generated emails. Secondly, duplicate versions of your articles may be created with the same URL but ending in "?doing_wp_cron". This can have severe implications for SEO, as search engines despise duplicate content. Moreover, the redirects and canonicalization caused by these duplicates will point to the wrong version, resulting in your pages being dismissed from search engine listings and an influx of 404 and soft 404 errors.

How to Solve WP-Cron Job Errors Caused by WordPress Hosting

Fixing this problem is a three-step process that can be accomplished quickly and painlessly:

1. Disable wp-cron.php

To stop wp-cron.php from causing further issues, access the file through your WordPress software. You can do this via your host's cPanel controls or an FTP client. Once you have found the wp-config.php file, open it and add the following line:

define('DISABLE_WP_CRON', true);

Save a copy of the file before making any changes, and remember to use an FTP client like Filezilla for easy and secure access.

2. Set Up a Manual Cron Job

Instead of relying on WordPress, set up a manual cron job through your hosting company's cPanel. The exact location may vary depending on your host, but you'll typically find it under "Scheduled Tasks" or "Cron Jobs." Enter the script to run, such as "/usr/bin/php5 /home/sites/yourdomainname/public_html/wp-cron.php", ensuring you use the correct PHP version. You can adjust the frequency of the manual cron job based on your website's traffic.

3. Redirect the Incorrect URLs

To direct users and search engines to the correct pages, add a rewrite rule in your .htaccess file. Find the file in your public.html folder using your FTP client and add the following line:

RewriteCond %{QUERY_STRING} (^|&)\doing_wp_cron=[0-9]+.[0-9]+(&|$) [NC]
RewriteRule ^ %{REQUEST_URI}? [R=301,L]

This rewrite rule will automatically redirect any URLs with "?doing_wp_cron" to the correct ones. This ensures that users are directed to the right place and search engines can easily identify the correct URL. Using a 301 redirect also preserves the value of any external links to the duplicate URLs.

Troubleshooting WP-Cron Job Errors

In case you encounter issues with this fix, consider the following:

  • Double-check that you're using the correct PHP version in the code for the manual cron job.
  • Ensure you don't have 'ALTERNATE_WP_CRON', true in your .htaccess file, as it can cause server errors.

In summary, to fix WP-Cron Job errors caused by WordPress hosting:

  1. Disable wp-cron.php.
  2. Set up a manual cron job.
  3. Redirect the incorrect URLs.
  4. Test the fix and repeat the process for all affected WordPress installations.

By following these steps, you can easily resolve WP-Cron Job errors and optimize your website's performance, usability, and SEO.

1