Typecho登陆后归档页面私密文章不显示的解决方法

Posted on

Typecho登陆后,打开归档页面,设置为“私密”属性的文章并不能显示,一定程度上影响了使用体验。

编辑Typecho根目录下的var/Widget/Contents/Post/Recent.php 文件,将

$this->db->fetchAll($this->select()
->where('table.contents.status = ?', 'publish')
->where('table.contents.created < ?', $this->options->time)
->where('table.contents.type = ?', 'post')
->order('table.contents.created', Typecho_Db::SORT_DESC)
->limit($this->parameter->pageSize), array($this, 'push'));

改为

if ($this->user->hasLogin()) {
    $this->db->fetchAll($this->select()
    ->where('table.contents.status = ? OR table.contents.status = ?', 'publish','private')
    ->where('table.contents.created < ?', $this->options->time)
    ->where('table.contents.type = ?', 'post')
    ->order('table.contents.created', Typecho_Db::SORT_DESC)
    ->limit($this->parameter->pageSize), array($this, 'push'));
} else {
    $this->db->fetchAll($this->select()
    ->where('table.contents.status = ?', 'publish')
    ->where('table.contents.created < ?', $this->options->time)
    ->where('table.contents.type = ?', 'post')
    ->order('table.contents.created', Typecho_Db::SORT_DESC)
    ->limit($this->parameter->pageSize), array($this, 'push'));
}

修改完成后,登录并打开归档页面,就可以看到设置为“私密”的文章啦

添加新评论