WordPress.org

Ready to get started?Download WordPress

Forums

Archives by Year : Month (10 posts)

  1. mdrdsr
    Member
    Posted 8 years ago #

    I have spent a lot of time trying to figure out how to and looking on the NET for examples how to:

    Display my archives as such:

    2006: Jan Feb March April (etc....)
    2005: Jan Feb March April (etc...)

    I have a PAGE for my archives and so far have it displaying the years with the following:

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

  2. "><?php echo $year; ?>
  3. <?php endforeach; ?>

    Does anyone have an example of how I can cycle through each valid archive year and display a link by month within each year?

    Thanks in advance!!

  • Kafkaesqui

    Posted 8 years ago #

    http://wordpress.org/support/topic/62859#post-335162

    I swear there's a pattern to these requests! :)

  • vkaryl
    Member
    Posted 8 years ago #

    Y'know what it is partially: most folks really only look at the stuff on the main support page without ever realizing that there's other forums to look through. So there's no post within those 40 or however many show up as latest so they post without knowing that a similar request had already been asked and probably answered three times earlier today....

  • Kafkaesqui

    Posted 8 years ago #

    Oh, I'm well aware of why these things are missed. (LET'S FIX SEARCH!)

    My point was more one of irony where when it comes to this sort of stuff, I often find myself linking back several times within a few days since the first time I replied on an issue. It can then go for weeks or months before I come across another similar request.

    Patterns. I see them everywhere (especially in the wallpaper).

  • vkaryl
    Member
    Posted 8 years ago #

    You sure those aren't just flyspecks? Yeah, I get you.... I was sort of hoping to promote (gently) a small sea-change....

  • mdrdsr
    Member
    Posted 8 years ago #

    Kafkaesqui - I tried your previous post and wrestled with it for hours, I could not get it to work. The months never displayed.

  • Kafkaesqui

    Posted 8 years ago #

    This code doesn't work?

    http://guff.szub.net/source/sample-62859.php

    If so, what version of WordPress this is running off of? Also, where is the code being used (such as sidebar template, archive query, Page template)?

  • mdrdsr
    Member
    Posted 8 years ago #

    I found this http://www.blindmuse.com/blog/2004/03/31/group-archives-by-year/ and it works. I am running WP 2 with Gallery 2.

    Thanks for the previous post, it contained this link.

  • Kafkaesqui

    Posted 8 years ago #

    Well, as long as you got things working the way you want.

  • fabioassis
    Member
    Posted 7 years ago #

    I'm using Guff's code.

    But how can I add the number of posts after the month? Like:

    2006
    September (3)
    August (5)

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags