请注意,本文编写于 314 天前,最后修改于 305 天前,其中某些信息可能已经过时。
第一步
/*热门
文章*/
function HotPosts() {
$archive = Typecho_Widget::widget('Widget_Archive');
$hotNums = 5; //热门文章数
$minViews = 10; //最低阅读量
$db = Typecho_Db::get();
$select = $db->select()->from('table.contents')
->where('table.contents.type = ?', 'post')
->where('table.contents.status = ?', 'publish')
->limit($hotNums);
$select->order("table.contents.views", Typecho_Db::SORT_DESC);
if ($minViews > 0) {
$select->where('table.contents.views >= ?', $minViews);
}
$rows = $db->fetchAll($select);
foreach ($rows as $row) {
$HostPostList[] = $archive->filter($row);
}
return $HostPostList;
}
放到主题目录下的functions.php,没有functions.php的话就放到sidebar.php.
放好函数,就可以把它加到侧边栏了,任何界面都显示,在sidebar.php合适的位置加入以下代码.
第二步.txt
版权属于:Rileysion's Blog
本文链接:https://www.zyysvip.cn/150.html
转载时须注明出处及本声明
全部评论 (暂无评论)
info 还没有任何评论,你来说两句呐!