Wordpress archive list with year, month, days, posts and comment counts -


i willing achieve wordpress archive list this:

2013

may (2)

04 - love wordpress (3 comments)
01 - love wordpress (1 comment)

february (1)

02 - love wordpress?

2012

...

from read elsewhere have create own query. not 1 may call developer. here's started with:

<ul> <?php $args=array(     'post_type' => 'post',     'posts_per_page' => '500', /*no limit, how?*/     'orderby' => 'date',     'order' => 'desc',     ); query_posts($args); while (have_posts()) : the_post(); ?>  <li><?php the_time('j'); ?> | <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>  <?php comments_number( '', '(1)', '(%)' ); ?></li>  <?php endwhile; ?> </ul> 

you can see looks here: http://www.vie-nomade.com/archives/

i know need separate month, year. thanks.

you may want consider performance issues related query published posts.

i got similar list, displaying number of posts in each month, in total, got 70 queries db, if change display every post got in blog, number goes 531 queries. (including other funcionality on site, of course)

montly list: showing how many post per month

every post list: with every published post

if decide go monthly list, can use wp_get_archives.

[/end of warning]

if don't write , got few posts, should this:

<ul class="years"> <?php $all_posts = get_posts(array(   'posts_per_page' => -1 // show posts ));  // variable contain posts in associative array // 3 levels, every year, month , posts.  $ordered_posts = array();  foreach ($all_posts $single) {    $year  = mysql2date('y', $single->post_date);   $month = mysql2date('f', $single->post_date);    // specifies position of current post   $ordered_posts[$year][$month][] = $single;  }  // iterates years foreach ($ordered_posts $year => $months) { ?>   <li>      <h3><?php echo $year ?></h3>      <ul class="months">     <?php foreach ($months $month => $posts ) { // iterates moths ?>       <li>         <h3><?php printf("%s (%d)", $month, count($months[$month])) ?></h3>          <ul class="posts">           <?php foreach ($posts $single ) { // iterates posts ?>              <li>               <?php echo mysql2date('j', $single->post_date) ?> <a href="<?php echo get_permalink($single->id); ?>"><?php echo get_the_title($single->id); ?></a>  (<?php echo $single->comment_count ?>)</li>             </li>            <?php } // ends foreach $posts ?>         </ul> <!-- ul.posts -->        </li>     <?php } // ends foreach $months ?>     </ul> <!-- ul.months -->    </li> <?php } // ends foreach $ordered_posts ?> </ul><!-- ul.years --> 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -