The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Archive by Year too? (3 posts)

  1. Janyuill
    Posted 7 years ago #

    I have a very long list of postings by the month, in my archives list.

    Would it not be possible to add an additional level of year, so that past years, when clicked would have the list of months, and then the list of postings?

    I am using - WordPress Default 1.6 by Michael Heilemann. Maybe other themes have the year level?


  2. whooami
    Posted 7 years ago #


    theres an example on that page, about 1/2 way down.

    edit your theme, add the necessary code, and youre done.

  3. Janyuill
    Posted 7 years ago #


    Well, I copied the code ...

    • <h2>Archives</h2>

        $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date DESC");
        foreach($years as $year) :

      • "><?php echo $year; ?>
      • <?php endforeach; ?>

    ... and added it to the Archives Page Template after the other code. No go.

    Then I added it before all of the other code. No go.

    And then I removed all of the original code, and pasted it in. No go.

    I know just enough to make me dangerous.

    What exactly do I do with the code (presuming, that I have the right one)?



Topic Closed

This topic has been closed to new replies.

About this Topic