建网站

WordPress定时发布失败的几个解决办法

微信扫一扫,分享到朋友圈

WordPress定时发布失败的几个解决办法
收藏 0 45

最近大同E网改版之后,废弃原有的臃肿的discuz,改为wordpress,有大量数据需要迁移,某些数据需要手动发布,为了讨好搜索引擎,我采用了规律的定时发布方法,前一天选好了第二天的发布时间,第二天发现wordpress没有按时把文章发出去,在网上查了一下WordPress定时发布失败是什么原因,找到了几个解决WordPress定时发布失败的方法。

WordPress默认发布文章的时间是0.01秒,一旦超过这个时间而没有发布成功,定时发布文章就会失败。如何解决Wordpress定时发布失败呢?下面有两种方法。

方法一:修改 /wp-includes/cron.php 系统文件

打开wp-includes目录下面的cron.php文件,找到“timeout”代码:
wp_remote_post( $cron_url, array( 'timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters( 'https_local_ssl_verify', true ) ) );

将代码后面的数值0.01修改为比0.01大就可以了,也可以修改为10.00。

但是不是很推荐这种方法,因为WordPress版本更新后,你需要再次修改这个文件。

二.解决WordPress定时发布失败修改post_status字段,解决定时发布失败

替换wp_posts里post_status字段里的 inherit 为publish
SQL可以这样写:
update wp-posts setpost_status=REPLACE(post_status,’inherit’,’publish’);

方法三 :使用WP Missed Schedule插件
直接使用WP Missed Schedule完美解决了这个WordPress定时发布失败的烦恼!

安装启用即可;如果你不想安装插件,也可以直接将该插件的代码添加到 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.0920.2011 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`='future'LIMIT 0,5");
		if(!count($scheduledIDs))return;
		foreach($scheduledIDs as$scheduledID){if(!$scheduledID)continue;
		wp_publish_post($scheduledID);}
		}
	add_action('init','wpms_init',0)
?>

第一种方法的缺点是,每次wordpress更新之后,都要重新到服务器上修改这个文件。

第二种方法的缺点是,直接操作数据库,容易失误!大家可以先备份数据库再进行操作!

我还没有学会写个人说明!

关注:国务院机构改革方案提交审议 新国家部委机关即将亮相

上一篇

SpringBoot 应用部署于外置 Tomcat 容器

下一篇

你也可能喜欢

45 条评论

  1. tadalafil tablets – buy tadalafil online cheap tadalafil generic date

  2. propecia – http://finasteridepls.com/ generic finasteride vs propecia reddit

  3. finasteride results after 6 months – 3 month finasteride results finasteride 5mg

  4. tadalafil 5 mg – http://xtadalafilp.com/ generic tadalafil online

  5. Birzte – http://virviaga.com/ female viagra pill

  6. Aekdif – lasix uses Tqrdis xkwxnt

  7. Rdnbhs – cialis pills Jbvwjp fqpzvi

  8. Greetings! Very uѕeful advіce in this particular article!
    It is the little changes that produce the largest changes.
    Thanks foг sharing!

    Here is my website :: payday loans minnesota

  9. Ezeyzt – silagra Ywzujp koiqny

  10. tadacip cipla – tadacip paypal tadacip cost

  11. celebrex 200 mg india – generic for celebrex celecoxib 200mg pharmacy

  12. individual level diagnosis community organizer synonym , positive feedback oxytocin. community action agency near me lyrica anticonvulsant buy pregabalin , community colleges near me online classes community definition rhetoric community health center union nj , community of faith bible church youtube mainstreet community bank near me? community support advocates jobs followers bot, first keystone community bank near me individual level of ecology.
    community action agency talladega , community recognition synonym positive reinforcement classical conditioning community health center.

  13. stromectol 12mg – ivermectin 10 ml generic ivermectin

  14. generic levitra reviews levitra professional samples how much does levitra cost at walmart?

  15. 2020 design software requirements drawing program website to buy Autocad software office depot quicken software. software bilancio xbrl 2020 office software suites free engeeeneringu#$sssaunnplus , win10-radeon-software-adrenalin-2020. office ergonomics software, 2020 software montreal download jamb cbt software 2020 for pc best office suite for mac os. microsoft office software geeks software intern winter 2020, software conferences 2020 uk.

  16. nexium 40 mg price australia – yasmin order online canada nexium price uk

  17. 40 mg prednisone daily – compare prednisone prices corticosteroids prednisone

  18. where can you buy viagra in australia – viagra professional is it safe where can i order viagra online

  19. how to buy viagra in us – comprar viagra original en 24 horas sildenafil citrate pfizer

  20. lyrica 75 mg medicine – lyrica pills 50 mg lyrica price australia

  21. yasmin generic brand australia – otc nexium 22 mg topamax rxlist

  22. ivermectin coronavirus – ivermectin 0.5 lotion stromectol where to buy

  23. stromectol 3 mg price – stromectol pill for humans ivermectin 8000 mcg

  24. what is tinder , tinder online
    tinder website

  25. 16mg ondansetron – ondansetron in mexico generic zofran online

  26. ivermectin for humans – ivermectin topical ivermectin 12mg

发表评论

您的电子邮件地址不会被公开。 必填项已用 * 标注

提示:点击验证后方可评论!

插入图片