Mysql代码如下:
1、以当前时间为起始时间,以1个小时为间隔,更新所有文章的发布日期。
SET @publish_date = NOW();
SET @interval = 1 * 60 * 60;
SET @max_id := (SELECT MAX(ID) FROM `wp_posts`);
update `wp_posts` SET `post_date` = DATE_SUB(@publish_date, INTERVAL ((@max_id-ID) + 1) * @interval SECOND);
update `wp_posts` set `post_modified` = `post_date`;
update `wp_posts` set `post_date_gmt` = `post_date`;
update `wp_posts` set `post_modified_gmt` = `post_modified`;
update `wp_posts` set `post_status` = 'publish';
2、随机选择3篇旧文章更新发布日期
UPDATE wp_posts
SET post_date = NOW()
WHERE ID IN (
SELECT ID
FROM (
SELECT ID
FROM wp_posts
WHERE post_type = 'post'
AND post_status = 'publish'
ORDER BY RAND()
LIMIT 1
) AS random_posts
)