EDIT:当我设置一个贴子并将其日期设置为2016年7月7日时,它目前正在工作。到目前为止,我的代码是:我添加了以下内容,以在帖子变粘时更改帖子的发布日期:
// Update post timestamp
$newdate = current_time(\'mysql\');
$my_post = array(
\'ID\' => $post_id,
\'post_date\' => $newdate
);
wp_update_post($my_post);
// Update post timestamp
如果帖子有粘性且超过7天,也可以使用此选项来解除帖子的粘贴:function deleteOldStickies($post_id, $postDate) {
$postDate = strtotime($postDate);
$currentTime = strtotime(time());
$expire = $currentTime + strtotime(\'-1 day\');
if ($postDate < $expire && is_sticky()) {
unstick_post($post_id);
echo \'Обявата е изтекла!\';
}
}
在内容中。php我将函数调用为:<?php echo deleteOldStickies($post->ID, $post->post_date); ?>
从上面的信息中,我进一步的问题是——我是否遗漏了一些重要的东西,它在生活环境中是否会起到良好的作用?