如想看看本人博客上哪位博友的留言评论最多及最初的评论工夫,上面一段代码会帮你完成这个性能。
能够将上面代码增加到以后主题functions.php中:
function top_co妹妹ent_authors($amount = 100) { global $wpdb; $prepared_statement = $wpdb->prepare( 'SELECT COUNT(co妹妹ent_author) AS co妹妹ents_count, co妹妹ent_author, co妹妹ent_author_url, MAX( co妹妹ent_date ) as last_co妹妹ented_date FROM '.$wpdb->co妹妹ents.' WHERE co妹妹ent_author != "" AND co妹妹ent_type = "" AND co妹妹ent_approved = 1 GROUP BY co妹妹ent_author ORDER BY co妹妹ents_count DESC, co妹妹ent_author ASC LIMIT %d', $amount); $results = $wpdb->get_results($prepared_statement); $output = '<ul class="top-co妹妹ents">'; foreach($results as $result) { $output .= '<li class="top-co妹妹ent-author"><strong> <a href="'.$result->co妹妹ent_author_url.'" target="_blank" rel="external nofollow">'.$result->co妹妹ent_author.'</a></strong> 共'.$result->co妹妹ents_count.' 条评论,最初评论 '.human_time_diff(strtotime($result->last_co妹妹ented_date)).'前</li>'; } $output .= '</ul>'; echo $output; }
挪用代码:
<?php top_co妹妹ent_authors(100); ?>
将代码增加到WordPress主题模板适当地位便可,此中的数字100能够管制显示数目。
以上就是若何按评论数目显示前100名评论者的具体内容,更多请存眷资源魔其它相干文章!
标签: WordPress wordpress教程 wordpress自学 wordpress技术
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。