zblog php指定最近多少天热门文章、热评文章
河南网站建前面有发布过zblog php调用热门文章、阅读浏览数最多的文章列表的代码,调用的是全站的热门文章,现在的需求是调用指定最近多少天发布的热门文章,实现周排行、月排行、年排行的热门文章列表的需求,实现方法把前面的代码稍作修改即可。
把以下代码添加到主题的include.php文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 | function boke8_hot($day){
global $zbp;
$hot = '';
$nowtime = time();
$settime = $day*24*60*60;
$gettime = $nowtime-$settime;
$array = $zbp->GetArticleList(array('*'),array(array('=','log_Status','0'),array('>','log_PostTime',$gettime)),array('log_ViewNums'=>'DESC'),array(10),'');
foreach ($array as $article) {
$hot .= '<li><a href="'.$article->Url.'" title="'.$article->Title.'" target="_blank">'.$article->Title.'</a></li>';
}
$hot .= '';
return $hot;} |
调用最近7天的热门文章:
1 | {boke8_hot('7')} |
把数字 7 改为自己要调用的天数即可。
扩展:把代码中的 log_ViewNums 改为 log_CommNums ,调用的是热评文章。
本文链接:https://h.finchui.com/zblogcn/1386.html 转载需授权!











在线咨询