Archive page listed monthly – but I have one problem
-
According to this post
https://www.ads-software.com/support/topic/display-archive-by-month-and-then-post-by-postI’ve been trying to show archive like:
January 2012
dd.mm.yy – post
dd.mm.yy – postFebruary 2012
dd.mm.yy – post
dd.mm.yy – postBut it shows like always have one post of the current month and repeat current month below
October 2012
03.10.2012 – postOctober 2012
02.10.2012 – post
01.10.2012 – posthere is the code please help me try to fix it
<?php // Variables $month, $prevmonth, $year and $prevyear are used to section the archive display ?> <?php $month = ''; $prevmonth = ''; $year = ''; $prevyear = ''; ?> <?php // Cycle through all the posts to display the archive ?> <?php query_posts('showposts=-1'); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php // Find the month/year of the current post ?> <?php $year = mysql2date('Y', $post->post_date); ?> <?php $month = mysql2date('F', $post->post_date); ?> <?php // Compare the current month with the $prevmonth ?> <?php if ($month != $prevmonth) { ?> <?php // If it is different, display the new month and reset $prevmonth ?> <br/><br/><h3><?php echo $month . ' ' . $year; ?></h3><br/> <?php $prevmonth = $month; ?> <?php // In case the previous post was a year ago in the same month ?> <?php } elseif ($year != $prevyear) { ?> <h3><?php echo $month . ' ' . $year; ?></h3> <?php $prevmonth = $month; ?> <?php $prevyear = $year; ?> <?php } ?> <?php // Display the post in this month ?> <p ><a class="list_archive" href="<?php the_permalink(); ?>"><?php echo mysql2date('d.m.y', $post->post_date); ?> - <?php the_title(); ?></a></p> <?php endwhile; endif; ?> <br/>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Archive page listed monthly – but I have one problem’ is closed to new replies.