我正在創建一個wordpress小部件以顯示過去4天內評論最多的文章。Wordpress查詢在X天內顯示大多數評論文章
我有這個迄今爲止
global $wpdb;
global $pagepost;
function filter_where($where = '') {
// posts in the last 4 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-4 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
$the_query = new WP_Query('posts_per_page=4;orderby=comment_count');
remove_filter('posts_where', 'filter_where');
?>
<ul>
<?php while ($the_query->have_posts()) : $the_query->the_post();
echo "<li>";
echo "<a href='".get_permalink()."' class='linkTitle'>";
echo get_the_title();
echo "</a>";
woo_post_meta();
echo "<div class='fix'>";
echo "</li>";
endwhile;
echo "</ul>";
wp_reset_postdata();
從什麼我能找到在WordPress網站應該從過去的4天COMMENT_COUNT
責令退還文章,但它只是顯示了我最後的4文章,我敢肯定,我在這裏做的很明顯是錯誤的,但我無法得到它
我想4篇文章發表最多評論文章發佈在過去4天。
有人請保存什麼小頭髮,我已經離開
只是一個查詢問題 - 在這裏使用「;」是否正確? posts_per_page = 4; orderby = comment_count我猜它是&?? – swapnesh
我將它改爲&但沒有改變......它似乎接受了兩個? –