WordPress.org

Ready to get started?Download WordPress

Forums

How to list archives menu yearly and monthly (3 posts)

  1. thomas514
    Member
    Posted 2 years ago #

    Hi, I want to list archives menu yearly and monthly on my website, which means to use wp_get_archives I guess but I want to show years and below each year, I would like months listed, like so:

    2011
    august
    july
    june
    may
    april
    mars
    february
    january
    2010
    april
    mars
    february
    january
    etc.

    Any idea how to do that?

  2. keesiemeijer
    moderator
    Posted 2 years ago #

  3. thomas514
    Member
    Posted 2 years ago #

    Thanks for the reply keesiemeijer!
    But I have this error message when I add the follofing code:

    <?php query_posts('posts_per_page = -1'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
     <?php
     $Year= get_the_date( 'Y' );
     $Month = get_the_date( 'F' );
     $Day = get_the_date( 'j' );
     ?>
      <?php if($Year != $temp_year) : ?>
      <h2><?php echo $Year ?></h2>
      <?php endif; ?>
      <?php if($Month != $temp_month || $Year != $temp_year) : ?>
      <h3><?php echo $Month; ?></h3>
      <?php endif; ?>
        <li><span><?php echo $Day; ?></span><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
      <?php
      $temp_year = $Year;
      $temp_month = $Month;
    	?>
    <?php endwhile; endif; ?>

    Fatal error: Call to undefined function get_the_date()

Topic Closed

This topic has been closed to new replies.

About this Topic