2012-03-23 129 views
2

我需要編寫一個WordPress查詢來完成以下任務 - 我正在一個每天有40-50個帖子的網站上工作 - 我想按日期顯示帖子「分組」。在Wordpress中按日期分組帖子

例如

20 March 2012 
post 1 
post 2 
post 3 

19 March 2012 
post 4 
post 5 
post 6 

我應該使用超過1個查詢做到這一點,是有可能做到這一點,而無需編寫自定義的SQL查詢。

我想分組的帖子。

+0

你有沒有考慮設置你的永久鏈接設置日期:

在這裏查詢
$args = array('posts_per_page' => -1, 'orderby' => 'date'); $myQuery = new WP_Query($args); $date = ''; if ($myQuery->have_posts()) : while ($myQuery->have_posts()) : $myQuery->the_post(); if ($date != get_the_date()) { echo $date; echo '<hr />'; $date = get_the_date(); } the_title(); // or whatever you want here. echo '<br />'; endwhile; endif; wp_reset_postdata(); 

更多信息?然後url http://example.com/2012/03/23將拉2012年3月23日的所有帖子。 – dnagirl 2012-03-23 15:39:20

回答