国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

DEDECMS|帝國CMS|Discuz|PHPCMS|Wordpress|ZBLOG|ECSHOP|蘋果CMS|極致CMS|CMS系統|

服務器之家 - 建站程序 - Wordpress - WordPress 實現文章評論排行榜

WordPress 實現文章評論排行榜

2019-09-11 15:25WordPress之家 Wordpress

本文主要用到了WordPress功能函數Query_post()的一種高級用法,就是獲取本周或當月或最近30天評論最多的一定數量的日志,需要的朋友可以參考下

用到了WordPress功能函數Query_post()的一種高級用法,就是獲取本周或當月或最近30天評論最多的一定數量的日志。

使用方法是將以下各段代碼放置到需要顯示最熱日志的主題模板文件中適當的位置即可,如邊欄(sidebar.php)。

所有時間內評論最多日志

  1. <ul> <?php query_posts('postpost_type=post&posts_per_page=10&orderby=comment_count&order=DESC'); while (have_posts()): the_post(); ?> 
  2. <li><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li> 
  3. <?php endwhile; wp_reset_query(); ?> 
  4. </ul> 

這段代碼默認顯示前10篇評論最多的日志,數量10可修改為其它數值。
本周評論最多日志
要顯示本周評論最多日志,我們就可以使用如下的代碼,也就是在前面代碼的基礎上再添加一些額外的參數來實現:

  1. <ul> <?php $week = date('W'); $year = date('Y'); query_posts('postpost_type=post&posts_per_page=10&orderby=comment_count&order=DESC&year=' . $year . '&w=' . $week); while (have_posts()): the_post(); ?> 
  2. <li><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li> 
  3. <?php endwhile; wp_reset_query(); ?> 
  4. </ul> 

最近30天評論最多日志

  1. <ul> <?php function filter_where($where = '') { //posts in the last 30 days $where ." AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'"; return $where; } add_filter('posts_where', 'filter_where'); query_posts('postpost_type=post&posts_per_page=10&orderby=comment_count&order=DESC'); while (have_posts()): the_post(); ?> 
  2. <li><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li> 
  3. <?php endwhile; wp_reset_query(); ?> 
  4. </ul> 

“30 days”可以根據需要修改為其他值(如“1 year”, “7 days”, 等)。

本月評論最多日志
類似地,顯示當月評論最多的日志,可以使用下面的代碼:

  1. <ul> <?php $month = date('m'); $year = date('Y'); query_posts('postpost_type=post&posts_per_page=10&orderby=comment_count&order=DESC&year=' . $year . '&monthnum=' . $month); while (have_posts()): the_post(); ?> 
  2. <li><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li> 
  3. <?php endwhile; wp_reset_query(); ?> 
  4. </ul> 

歡迎補充說明~

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 99国产视频 | 精品久久久久久久久久久 | 久久影视精品 | 亚洲在线看 | 欧美片网站免费 | 欧美日韩一区二区三区在线观看 | 亚洲国产成人av好男人在线观看 | 黄色a级网站| 亚洲福利在线观看 | 亚洲91 | 国产精品爱久久久久久久 | 精品国产欧美一区二区三区成人 | 亚洲精品在线播放视频 | 精品国产视频 | 日本精品在线观看 | 亚洲精品一区二区网址 | 午夜剧场在线免费观看 | 国产精品久久久久无码av | 国内精品久久久久久中文字幕 | 视频黄色免费 | 黄色av电影 | 国产精品无码久久久久 | 日韩av免费在线观看 | 免费观看国产精品 | 91精品国产91久久久久久吃药 | 成人欧美一区二区三区视频xxx | 日韩国产欧美亚洲 | 亚洲国产婷婷香蕉久久久久久99 | 日韩精品二区 | 992人人tv香蕉国产精品 | 亚洲精品中文字幕在线观看 | 福利片在线 | 成人在线免费观看视频 | 精品久久久精品 | 在线观看av网站永久 | 毛片一级av | 日韩在线观看中文字幕 | 成人福利在线观看 | 亚洲电影第三页 | 国产主播福利 | 成人欧美|