2
我想显示上个月最特定类别的评论文章。 这是我现在的代码,我无法弄清楚这里有什么错,有什么想法?显示最近评论的帖子上个月wordpress
<?php
function filter_where($where = '') {
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
$the_query = new WP_Query(array('posts_per_page' => 3, 'cat' => 2, 'orderby' => 'comment_count date', 'order'=> 'DESC'));
remove_filter('posts_where', 'filter_where');
?>
<?php while ($the_query->have_posts()) : $the_query->the_post();
echo get_the_title();
// and rest of content
endwhile;
wp_reset_postdata(); ?>
编辑:p.s.顺便说一句,我正在使用Vkontakte Api插件为我的意见。可能是问题出在这里,因为这段代码在其他站点上确实可以正常工作。但是,get_comments_number()显示正确的数字,为什么然后orderby => comment_count不起作用?
不幸的是,这并没有帮助。无论如何,谢谢 – Dolohov
@Dolohov:你可以运行MySQL并让我看看是否收到任何文章?只需将你的表格前缀替换成你的。 –
我正在接受他们。但不按comment_count排序。顺便说一句,我添加了一些更多的信息昨天,IDK,如果你注意到或不 – Dolohov