如何控制WordPress文章的发布间隔时间

Wordpress朋友们在使用WordPress博客发布文章的时候可能会遇到这种情况,如果有时间的话大家就会陆续发布好几篇文章。但是我们都知道短时间内连续发文章是不利于SEO优化和用户体验的,每篇文章的发布时间有一定时间间隔或许更适合读者。除了我们设置定时发布文章还有一种方法,下面我们就给大家介绍下,其实实现方法很简单。

如何控制WordPress文章的发布间隔时间

将代码添加到当前主题的 functions.php 文件中:

//设定每篇文章的发布间隔
function force_time_between_posts($data, $postarr) {
global $wpdb;
if (emptyempty($postarr[‘ID’])) return $data;
$latest = $wpdb->get_var(”
SELECT post_date
FROM {$wpdb->posts}
WHERE post_status IN(‘future’,’publish’)
AND post_type = ‘post’
AND ID != {$postarr[‘ID’]}
ORDER BY post_date DESC
LIMIT 1″);
$distance = 60; // 时间间隔(分钟)
$latest = strtotime($latest);
$current = strtotime($data[‘post_date’]);
if ($latest = 0 && $diff

chuangye

chuangye

chuangye

 

chuangye

Joomla的老巢