Solve the problem of WordPress publishing articles at regular intervals

Source: Internet
Author: User
Tags wordpress version

Solution

Function Bing_cron_request ($ request ){
$ Request ['args '] ['timeout'] = 2; // change the size of 2 if it cannot be released.
Return $ request;
}
Add_filter ('cron _ request', 'Bing _ cron_request ');

Solution 1

Modify the/wp-nodes des/cron. php system file

Open the cron. Php file under the wp-Des directory and find the "timeout" code:


Wp_remote_post ($ cron_url, array ('timeout' => 0.01, 'blocking' => false, 'sslverify '=> apply_filters ('https _ local_ssl_verify', true )));

You can change the value 0.01 after the code to a value greater than 0.01 or 10.00.

This method is not highly recommended because after the WordPress version is updated, you need to modify the file again.


Solution 2

Use WP Missed Schedule plug-in

Download WP Missed Schedule and install and enable it. If you do not want to install the plug-in, you can directly add the code of the plug-in to the end of functions. php:


<? Php
If (! Function_exists ('add _ action ')){
Header ('status 403 Forbidden '); header ('http/1.0 403 Forbidden'); header ('http/1.1 403 Forbidden '); exit ();}
?>
<? Php
Function wpms_log (){
Echo "\ n <! -- Plugin WP Missed Schedule 2011.0900002011 Active --> ";
  }
Add_action ('WP _ head', 'wpms _ log ');
Add_action ('WP _ footer ', 'wpms _ log ')
?>
<? Php
Define ('wpms _ delay', 5 );
Define ('wpms _ option', 'WP _ missed_schedule ');
Function wpms_replace (){
Delete_option (WPMS_OPTION );
 }
Register_deactivation_hook (_ FILE __, 'wpms _ replace ');
Function wpms_init (){
Remove_action ('Publish _ future_post ', 'Check _ and_publish_future_post ');
$ Last = get_option (WPMS_OPTION, false );
If ($ last! = False) & ($ last> (time ()-(WPMS_DELAY * 60) return;
Update_option (WPMS_OPTION, time ());
Global $ wpdb;
$ ScheduledIDs = $ wpdb-> get_col ("SELECT 'id' FROM '{$ wpdb-> posts }'". "WHERE (". "('post _ date'> 0) & ('post _ date' <= CURRENT_TIMESTAMP () OR ". "('post _ date_gmt'> 0) & ('post _ date_gmt' <= UTC_TIMESTAMP ()))". ") AND 'Post _ status' = 'futuristic 'LIMIT ");
If (! Count ($ scheduledIDs) return;
Foreach ($ scheduledIDs as $ scheduledID) {if (! $ ScheduledID) continue;
Wp_publish_post ($ scheduledID );}
  }
Add_action ('init ', 'wpms _ init', 0)
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.