• I want to list my archives by year, so that instead of:
    July 2005
    June 2005
    May 2005
    etc…

    I get:
    2005
    2004
    2003
    etc…

    I’ve read all the other forum posts on this, but I’m not interested in plugins that will make my archives look like this:
    2005 May
    June
    July
    2004 December
    November

    etc.

    I just want by YEAR.

    Also, I don’t know a lot about php, but why can’t this tag:

    <?php wp_get_archives('type=monthly'); ?>

    be changed to type=yearly ?? Why does “weekly” work, or “postbypost” by not yearly?

    Any help would be GREATLY appreciated! Thank you.

Viewing 15 replies - 16 through 30 (of 32 total)
  • Thanks a lot! That’s what I was looking for.
    Maybe the next version supports get_archives with yearly?!

    It would be perfect, to show the archives monthly for the actual year and yearly for previous years.
    I guess this code would be a little too complex.

    Aylwin (or anyone else looking to filter out future posts from the archive list), just alter the query code to this:

    $now = current_time('mysql');
    $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts AND post_date <= '$now' ORDER BY post_date");

    hartlrobert, you may be interested in this plugin:

    https://www.blindmuse.com/blog/2004/03/31/group-archives-by-year/

    (Just happened to stumble across the thread, hence the late reply…)

    Kafkaesqui, thanks.

    Kafkaesqui, thanks for the code. I managed to get it done somehow but your code looks cleaner.

    rinaldi, I’m not sure how you would do a collapsible menu without something like javascript unless you’re ok with the page reloading due to each change to the menu. For something where the months appear under a year when selecting it, you’d need a different bit of code than above which queries for years as well months within the current year.

    How exactly do I do this? For the months too appear under a year when I select it? I haven’t found any Plugins for this yet.

    Now I have the code written in this thread by Kafka and my Archives look like this:

    2006
    2005
    2004

    Now I would like it to look like this, selecting 2005

    2006
    2005
    January
    February

    December
    2004

    How do I do this?
    I’m new at PHP-coding but I do know HTML and CSS.

    Thanx

    Ninis, for that we make use of a bit of the behind-the-scenes info WordPress provides on archive (date-based) queries. As the code by now is a bit long for the forums, here’s a link to it:

    https://guff.szub.net/source/sample-39204.php

    Let me explain what you’ll see there (that is, what I didn’t add comments to):

    The first bit of code scoping the WordPress variables $month and $year to global is why I altered my year query vars to $arc_years/$arc_year.

    The second query in the code ($arc_months) collects the months for the current archive year, and goes through a similar foreach loop as for the years, using WP’s get_month_link() to display the monthly archive link.

    Note that to display a textual month value (July) rather than a numeric one (7), I do this:

    <?php echo $month[zeroise($arc_month, 2)]; ?>

    This makes use of the global $month array to match number to name. The zeroise() function assures a two digit number (i.e. 01 — required for a match in the $month array).

    Can someone look at https://chris.pirillo.com/ and tell me what his ‘archive’ code would look like?

    * 2006
    o October (20)
    o September (56)
    o August (83)
    o July (71)
    o June (105)
    o May (143)
    o April (66)
    o March (92)
    o February (118)
    o January (48)
    * 2005
    * 2004
    * 2003
    * 2002

    Can someone look at https://chris.pirillo.com/ and tell me what his ‘archive’ code would look like?

    It’s a plugin. In fact, it’s this one:

    https://blindmuse.com/blog/2004/03/31/group-archives-by-year/

    blindmuse.com has been down for a while, so I’ve posted the source for the plugin here:

    https://wordpress.pastebin.ca/209160

    ganzua

    (@ganzua)

    Id it possible to show the year and then the postbypost of that year?

    2006

    * post 12 title
    * post 11 title
    * post 10 title
    * post 9 title
    * post 8 title
    * post 7 title

    2005

    * post 12 title
    * post 11 title
    * post 10 title
    * post 9 title
    * post 8 title
    * post 7 title

    ganzua

    (@ganzua)

    up!

    Thank you very much for the trick !
    I’m now displaying archives by year, and reversed ??

    Hello:
    I’m using the Blindmuse plugin for my archives, but now the page won’t validate. I’ve used the plugin from here: https://wordpress.pastebin.ca/209160

    The Code:
    /*
    <h2>Archives</h2>

      <?php cg_get_archives_by_year(’24’, ’12’, ‘

    • ‘, ‘
    • ‘, ‘

      ‘, ‘

    ‘, ‘

      ‘, ‘

    ‘, false); ?>

    */

    shoot, I can’t get the lis and uls to show up.
    It’s located here: https://www.pistolotto.com

    You need to surround code with “backticks” – the weird symbol underneath the tilde (the other weird symbol) on the key to the left of the numeral 1 key on US keyboards….

    Oh, and this plugin from Viper will do something similar: https://www.viper007bond.com/wordpress-plugins/clean-archives-reloaded/

    Thanks…
    Here’s the code:

    <h2>Archives</h2>
    <ul>
    <?php cg_get_archives_by_year('24', '12', '<li>', '</li>', '<ul>', '</ul>', '<ul>', '</ul>', false); ?>
    </ul>

    Well, you’ll have to play with the nested listing looks like. You might start by removing the enclosing ul tagset, see what happens. This sort of thing is a total trial-and-error mess for me, why I hate nested lists.

    And your onload error may not ever go away – I’ve been looking for a fix for that myself, and haven’t found one.

Viewing 15 replies - 16 through 30 (of 32 total)
  • The topic ‘Archives by YEAR (this is different!)’ is closed to new replies.