WordPress函数:WP_Query 按评论数量查询文章
在WordPress中,强大的WP_Query还支持按评论数量查询文章。
需要使用 comment_count 参数,如果传入int,比如100,则查询评论数为100的文章;如果传入 Array,字段value为int,compare 则支持 '=', '!=', '>', '>=', '<', '<=' 等。
代码示例:
// 传入 int
$args = array(
'post_type' => 'post',
'comment_count' => 20,
);
$query = new WP_Query( $args );
// 传入 Array
$args = array(
'post_type' => 'post',
'comment_count' => array(
'value' => 25,
'compare' => '>=',
)
);
$query = new WP_Query( $args );
WP_Query 的基础用法可以参考文章:WP_Query 的基础用法简介
-
WordPress函数:human_time_diff 几秒几分几小时前WordPress 自带更友好的时间显示处理函数
-
WordPress函数:wp_is_mobile 判断是否是移动设备WordPress 中如何判断是否是移动设备
-
WordPress函数:wp_die 增强版的 PHP die函数wp_die 优雅的处理异常
-
WordPress函数:get_search_form 获取搜索表单如何在 WordPress 主题中添加搜索表单
-
WordPress函数:get_category_link()通过分类ID获取分类链接get_category_link()是一个通过分类ID获取分类链接的WordPress函数。该函数位于 wp-includes/category-template.php
-
WordPress函数:get_post_field 获取文章字段直接获取文章的字段
暂无评论,抢个沙发...