php - monthly post timeline for wordpress -
how can use code http://astheria.com/this-site/creating-a-timeline-style-archive-page (demo yearly archive) show posts on several month instead of year? example have 3 posts in jun 2015. , 2 posts in jan 2016 want sort posts in month. below
- jun 2015
- post1
- post2
- post3
- jan 2016
- post4
- post5
this code yearly archive:
<?php get_header(); query_posts('posts_per_page=-1'); $dates_array = array(); $year_array = array(); $i = 0; $prev_post_ts = null; $prev_post_year = null; $distance_multiplier = 2; ?> <?php while (have_posts()) : the_post(); $post_ts = strtotime($post->post_date); $post_year = date( 'y', $post_ts ); /* handle first year special case */ if ( is_null( $prev_post_year ) ) { ?> <h3 class="archive_year"><?=$post_year?></h3> <ol class="archives_list"> <?php } else if ( $prev_post_year != $post_year ) { /* close off ol */ ?> </ol> <?php $working_year = $prev_post_year; /* print year headings until reach post year */ while ( $working_year > $post_year ) { $working_year--; ?> <h3 class="archive_year"><?=$working_year?></h3> <?php } /* open new ordered list */ ?> <ol class="archives_list"> <?php } /* compute difference in days */ if ( ! is_null( $prev_post_ts ) && $prev_post_year == $post_year ) { $dates_diff = ( date( 'z', $prev_post_ts ) - date( 'z', $post_ts ) ) * $distance_multiplier; } else { $dates_diff = 0; } ?> <li style="margin-top:<?=$dates_diff?>px"><span class="date"><?php the_time('f j'); ?><sup><?php the_time('s') ?></sup></span> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li> <?php /* subsequent iterations */ $prev_post_ts = $post_ts; $prev_post_year = $post_year; endwhile; /* if we've processed @ least *one* post, close ordered list */ if ( ! is_null( $prev_post_ts ) ) { ?> </ol> <?php } ?>
thanks . best regards.
Comments
Post a Comment