WordPress 实现文章评论排行榜


当前第2页 返回上一页


代码如下:

<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('post_type=post&posts_per_page=10&orderby=comment_count&order=DESC'); while (have_posts()): the_post(); ?>
<li><a title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; wp_reset_query(); ?>
</ul>

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

本月评论最多日志
类似地,显示当月评论最多的日志,可以使用下面的代码:


代码如下:

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

欢迎补充说明~


标签:WordPress

返回前面的内容

相关阅读 >>

wordpress中调试缩略图的相关php函数使用解析

wordpress中设置post type自定义文章类型的实例教程

wordpress取消英文标点符号自动替换中文标点符号的优雅方法

在centos 6 中安装wordpress(一) 安装apache,mysql, php环境

wordpress评论ip地址显示为127.0.0.1的解决办法

详解wordpress中过滤链接与过滤sql语句的方法

wordpress主题支持自定义菜单及修改css样式实现方法

wordpress编辑器中添加链接功能自动加入nofollow的方法

wordpress中非插件实现嵌套回复效果的方法

wordpress 显示文章日期的方法

更多相关阅读请进入《wordpress》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...