Support » Plugins and Hacks » Hacks » Post Timeline

  • Hi all,

    I hope I’m posting this in the right place. I was hoping to get some help in creating a ‘post timeline’ to display previous posts on my blog, underneath the current post.

    This is what I’d like it to look like, where the numbers are the dates of the posts:
    ———————————————————————–
    ^ LATEST | 18 | 6 | < MAR | 28 | 14 | 10 | < FEB | 30 | 7 | 2 | < JAN |
    ———————————————————————–

    <?php
    	global $post;
    	$tmp = $post;
    	$args = array( 'numberposts' => 10 );
    	$myposts = get_posts( $args );
    	$currMonth = date('M');
    	foreach( $myposts as $post ) : setup_postdata($post);			if ($post->ID == $do_not_duplicate) continue;
    		   if (the_time('M') != $currMonth) { ?>
    		      <li><?php the_time('M'); ?></li>
    		   <? }; ?>
                         <li><a href="<?php the_permalink(); ?>"><?php the_time('jS'); ?></a></li>
             <?php
    	endforeach;
    	$post = $tmp;
             wp_reset_postdata();
    ?>

    This works to a degree, but it shows the month alongside each post date. I wonder if I have to create a variable to store the last month displayed, so that the result only outputs when the value changes?

    Any help would be appreciated!

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post Timeline’ is closed to new replies.