WordPress

WordPress Seasonal Archive Plugin

Posted on: January 20th, 2012 by Steve 5 Comments

Following on from my previous post, I've just completed another WordPress plugin. This time I've addressed an issue I had with the standard WordPress archive widget.

The project I've been working on requires the use of posts, however the client doesn't intend to be posting entries very frequently and so I was asked if the archive could be listed as Spring, Summer, Autumn and Winter rather than monthly.

My new Seasonal Archive plugin does just that.  Once installed, it creates a widget which displays links to your post archives in a seasonal format.  The seasons are determined as per below.

  • Spring - March to May
  • Summer - June to August
  • Autumn - September to November
  • Winter - January to February

The widget will display archive links in the following format (note the year overlap for Winter).

  • Spring 2011
  • Summer 2011
  • Autumn 2011
  • Winter 2011-12

You can see the plugin in action in the column to the right.  At the time of writing however this is only my third post so you will only see posts for Winter 2011-12 at the moment.

Download the SRWD Seasonal Archives WordPress Plugin

Unzip the contents of the download file and upload the folder to the /wp-content/plugins directory on your web server.  You will then be able to activate the plugin in the Plugins section of your WordPress dashboard.

You will then be able to make use of the Seasonal Post Archive widget in any widget-enabled area of your WordPress site.

As with my previous plugin, if you have any questions or comments, please let me know.

5 Responses

  1. charlotte

    February 2, 2012

    Hi Steve, I am trying to do something very similar to this – but I have assigned posts to categories which I want to display seasonally / monthly, it is a gardening site.

    So that if the current month is January I want to show category 6 and if the current month is february I want to show category 7 etc.

    I am tearing my hair out because I cannot it out I thought I would be able to do a simple if statement with the built in monthnum variable, but I cannot get it to work.

    If you could point me in the right direction I would really appreciate it.

    Reply
    • Steve

      February 3, 2012

      Hi Charlotte, can you please post your code so I can take a look at it? There should be a couple of different ways to do this depending on the database query you’re running.

      Reply
  2. charlotte

    February 7, 2012

    Hi Steve,
    Thank you so much for responding.

    I started with this – but it doesn’t work:

    Then I tried this

    Then I was thinking that something like this would work – but I don’t get how to do an array with variables

    7,
    ‘monthnum’ => 02,
    ‘order’ => ‘ASC’
    );
    query_posts( $args );?>

    sp I tried this

    $currentmonth,
    ‘cat’ => $cat,
    );
    array(
    ‘monthnum’ => 02,
    ‘cat’ => 8,
    );
    ?>

    But I am still lost with it. I know it should be straight forward, but it isn’t.

    Reply
  3. charlotte

    February 7, 2012

    It didn’t like me putting code in – here it is again without the php tags:

    Hi Steve,

    I started with this – but it doesn’t work:

    if ( $query_string . ‘monthnum=01′) {
    query_posts( ‘cat=7′);
    } elseif ( $query_string . ‘monthnum=02′) {
    query_posts( ‘cat=7′);
    }

    Then I tried this

    $current_month = date(‘m’);
    if ($query_string . ‘m=01′) {
    query_posts( ‘cat=7′);
    } elseif ($query_string . ‘m=02′) {
    query_posts( ‘cat=6′);
    } endif

    Then I was thinking that something like this would work – but I don’t get how to do an array with variables

    $args = array(
    ‘cat’ => 7,
    ‘monthnum’ => 02,
    ‘order’ => ‘ASC’
    );
    query_posts( $args );

    so I tried this

    $args = array(
    ‘monthnum’ => $currentmonth,
    ‘cat’ => $cat,
    );
    array(
    ‘monthnum’ => 02,
    ‘cat’ => 8,
    );

    php query_posts( $args );

    But I am still lost with it.

    Reply
  4. charlotte

    February 7, 2012

    I think I have cracked it!!!

    $today = date(“m”);
    if ($today == “01″) {
    query_posts(‘cat=7′);
    }
    elseif ($today == “02″) {
    query_posts(‘cat=4′);
    }

    Reply

Leave a Reply