王尘宇王尘宇

研究百度干SEO做推广变成一个被互联网搞的人

Typecho N天内批评最多的文章

Typecho N天内批评最多的文章


代码作用是N天内批评最多的N篇文章,这个N你能够本身定义,本身修正。
代码以下:

<?phpfunction rmcp($days = 30,$num = 5){    $defaults = array(        'before' => '<ul>',        'after' => '</ul>',        'xformat' => '<li>{title}<span class="subcolor">已有批评数:{commentsNum}</span></li>'    );    $time = time() - (24 * 60 * 60 * $days);    $db = Typecho_Db::get();    $sql = $db->select()->from('table.contents')            ->where('created >= ?', $time)            ->where('type = ?', 'post')            ->limit($num)            ->order('commentsNum',Typecho_Db::SORT_DESC);    $result = $db->fetchAll($sql);        echo $defaults['before'];        foreach($result as $val){            $val = Typecho_Widget::widget('Widget_Abstract_Contents')->filter($val);            echo str_replace(array('{permalink}', '{title}', '{commentsNum}'), array($val['permalink'], $val['title'], $val['commentsNum']), $defaults['xformat']);        }        echo $defaults['after'];}?>

挪用代码:

<?php rmcp(60,5);?>

这个挪用的意义是2个月内批评最多的前5篇文章


相关文章

评论列表

发表评论:
验证码

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。