WordPress:列出所有帖子,并按月分组;年

WordPress:列出所有帖子,并按月分组;年,wordpress,Wordpress,当我需要列出2011年按月份分组的所有帖子时,我会在WordPress中这样做(正如解释的那样非常简单): query_posts('monthnum=12&year=2011'); while(have_posts()):the_post(); 回音“”; _title(); 回音“”; 结束时; 现在,如何列出所有帖子并按月份和年份进行分组,而不知道我应该返回多远?也就是说,我不知道哪一年写的文章最早。从技术上讲,我可以尝试做monthnum=12&year=2010,monthnum=1

当我需要列出2011年按月份分组的所有帖子时,我会在WordPress中这样做(正如解释的那样非常简单):

query_posts('monthnum=12&year=2011');
while(have_posts()):the_post();
回音“
  • ”; _title(); 回音“
  • ”; 结束时;

    现在,如何列出所有帖子并按月份和年份进行分组,而不知道我应该返回多远?也就是说,我不知道哪一年写的文章最早。从技术上讲,我可以尝试做
    monthnum=12&year=2010
    monthnum=12&year=2009
    ,等等;但我觉得一定有更好的办法

    一种解决方案是在所有年份中循环:

     for($i=0;$i<10;$i++){
         $y=2011-$id;
         query_posts("monthnum=12&year=$y");
         while ( have_posts() ) : the_post();
            echo '<li>';
            the_title();
            echo '</li>';
         endwhile; 
     }
    
    对于($i=0;$i单击此项-
    
     for($i=0;$i<10;$i++){
         $y=2011-$id;
         query_posts("monthnum=12&year=$y");
         while ( have_posts() ) : the_post();
            echo '<li>';
            the_title();
            echo '</li>';
         endwhile; 
     }