Typecho如何在一个独立页面中遍历出所有文章?

我在后台创建了一张独立页面,并配了自定义模板。因为页面中需要遍历所有文章(包括:标题、作者、发布时间、内容、标签)请问我该如何写?谢谢!
补充:如果在模版中使用:<?php while($this->next()): ?>...<?php endwhile; ?>只能显示这个独立页面的文章内容,并不是整站所有的文章。求高手指教。

阅读 5.6k
1 个回答

自己读数据库吧。

$db = Typecho_Db::get();
$select = $db->select()->from('table.contents')
    ->where('type = ?', 'post')
    ->where('table.contents.status = ?', 'publish')
    ->where('table.contents.created < ?', time())
    ->order('table.contents.created', Typecho_Db::SORT_DESC);
$posts = $db->fetchAll($select);
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进