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