下面是主要代码(插入到 functions.php 中):
function Autofirst(){
$db = Typecho_Db::get();
$query = $db->select()->from('table.comments')->where('authorId = ?','0')->order('coid',Typecho_Db::SORT_DESC)->limit(100);
$result = $db->fetchAll($query);
$arrUrl = array();
$arrAuthor = array();
foreach ($result as $value) {
if($value["url"]!==null){
array_push($arrUrl,$value["url"]);
array_push($arrAuthor,$value["author"]);
}
}
$su=array_filter(array_merge(array_unique($arrUrl)));
$sa=array_filter(array_merge(array_unique($arrAuthor)));
$num=0;
for($i=0;$i<count(array_unique($su));$i++){
if($su[$i]!=="" && $num<16){
$num+=1;
$db1 = Typecho_Db::get();
$query1 = $db1->select()->from('table.comments')->where('url = ?',$su[$i])->order('coid',Typecho_Db::SORT_DESC)->limit(100);
$result1 = $db1->fetchAll($query1);
$arrAuthor1 = array();
foreach ($result1 as $value) {
array_push($arrAuthor1,$value["author"]);
}
echo '<a href="'.$su[$i].'" rel="external nofollow" class="item col-lg-3 col-md-3 visible-lg visible-md" target="_blank"><i class="glyphicon glyphicon-leaf"></i> '.$arrAuthor1[0].'</a>';
}
}
}
调用代码和 css:
此处内容需要评论回复后查看
本文来自投稿,不代表本站立场,如若转载,请注明出处:
0o2mz2