"> ');
本站使用了 Pjax 等基于 JavaScript 的开发技术,但您的浏览器已禁用 JavaScript,请开启 JavaScript 以保证网站正常显示!

WordPress文章日期批量随机修改

此方法对做WordPress批量采集的、发文章时间不符合实际的站点,例如文章状态为“草稿”很久了,原计划发布时间是上个月,结果这个月才完稿发布,类似情况很有帮助,省去一个个修改的烦恼。这是在网上找到的两段SQL语句,存在瑕疵:

//时间格式不对

UPDATE wp_posts SET post_date = DATE_ADD('2010-1-01', INTERVAL ROUND(RAND() * 3890+ 1) DAY) WHERE ID between 1 AND 100000;
update wp_posts set post_modified = post_date WHERE ID between 1 AND 100000;
update wp_posts set post_date_gmt = post_date WHERE ID between 1 AND 100000;
update wp_posts set post_modified_gmt = post_modified WHERE ID between 1 AND 100000;
update wp_posts set post_status = 'publish' WHERE ID between 1 AND 100000;

//时间格式不对
UPDATE wp_posts SET post_date = DATE_ADD('2018-1-10', INTERVAL ROUND(RAND() * 220 + 1) DAY) WHERE ID between 1 AND 1215;
update wp_posts set post_modified = post_date WHERE ID between 1 AND 1215;
update wp_posts set post_date_gmt = post_date WHERE ID between 1 AND 1215;
update wp_posts set post_modified_gmt = post_modified WHERE ID between 1 AND 1215;
update wp_posts set post_status = 'publish' WHERE ID between 1 AND 1215;
请输入图片描述
始时间 “2020-01-01”
随机日期范围 “180 天”
文章ID起始范围 “1 – 2000”
任意修改,然后依次执行以下SQL语句,每个分号是一句,一句一句执行,可以在指定的文章ID范围内,随机生成文章的发布日期,替换原来的日期。

//完美

UPDATE wp_posts SET post_date = DATE_ADD('2020-01-01', INTERVAL ROUND(RAND() * 180 + 1) DAY) WHERE ID between 1 AND 2000;
update wp_posts set post_modified = post_date WHERE ID between 1 AND 2000;
update wp_posts set post_date_gmt = post_date WHERE ID between 1 AND 2000;
update wp_posts set post_modified_gmt = post_modified WHERE ID between 1 AND 2000;
update wp_posts set post_status = 'publish' WHERE ID between 1 AND 2000;

字段含义:

  1. post_date(文章发布日期) post_date_gmt(文章发布日期,格林威治时间) post_modified(文章修改时间)
    post_modified_gmt(文章修改时间,格林威治时间) post_status(文章状态)
    如果安装WordPress的时候数据库表前缀wp有修改过,记得做相应更改。

正在加载...

推广

 继续浏览关于 的文章

 本文最后更新于:2022/05/13 14:38:00,可能因经年累月而与现状有所差异

 引用转载请注明:龙氏小哥 > 搬砖笔记 > WordPress文章日期批量随机修改

发现共鸣


Warning: curl_setopt() expects parameter 1 to be resource, null given in /www/wwwroot/blog.longshi.org/usr/themes/armx/functions.php on line 1531
如是说:辉煌一刻谁都有,别拿一刻当永久。

发表评论

'); pageInit(); NProgress.done(); var url = window.location.href; if(url.indexOf("comment")>-1 ){ $('html,body').animate({scrollTop: $('#comments').offset().top /*+ Ch*/ }, 500); } if(typeof Blazy != 'undefined' && Blazy instanceof Function){ $(document).ready(function(){ var blazy = new Blazy(); }); } } }); InstantClick.on('wait', function(){ //点击链接但未加载 NProgress.start(); NProgress.inc(); }); // InstantClick.on('receive',function(url){ //页面已预加载 // url // body // title // }); // InstantClick.on('fetch',function(url){ //页面开始预加载 // }); InstantClick.init('mousedown'); } pageInit();