Simple Yearly Archive Plugin// Making Archiving Easy & Elegant

Simple Yearly Archive is a rather neat and simple WordPress plugin that allows you to display your archives in a year-based list. It works mostly like the usual WP archive, but displays all published posts seperated by their year of publication. That said, it’s also possible to restrict the output to certain categories, and much more.

The plugin in action
The plugin requires WordPress 3.0+

  1. Download the plugin and unzip it.
  2. Upload the folder simple-yearly-archive/ to your /wp-content/plugins/ folder.
  3. Activate the plugin from your WordPress admin panel.
  4. Installation finished.

  1. Deactivate the plugin from your WordPress admin panel.
  2. Upload the folder simple-yearly-archive/ to your /wp-content/plugins/ folder and overwrite the existing file.
  3. Activate the plugin from your WordPress admin panel.

Implementation / Usage

Since WordPress 2.5 the function can be called with a shortcode:
[apache]

2012201120082007200620052004

2012 (6)

2011 (1)

2008 (1)

2007 (4)

2006 (20)

2005 (13)

2004 (1)

Plugin by Oliver Schlöbe
[/apache]
Some examples follow - each is a proper invocation of the plugin:
[apache]

2012201120082007200620052004

2012 (6)

2011 (1)

2008 (1)

2007 (4)

2006 (20)

2005 (13)

2004 (1)

Plugin by Oliver Schlöbe
[/apache]
[apache]

2012201120082007200620052004

2012 (6)

2011 (1)

2008 (1)

2007 (4)

2006 (20)

2005 (13)

2004 (1)

Plugin by Oliver Schlöbe
[/apache]
[apache]

2012201120082007200620052004

2012 (6)

2011 (1)

2008 (1)

2007 (4)

2006 (20)

2005 (13)

2004 (1)

Plugin by Oliver Schlöbe
[/apache]
[apache]

2012201120082007200620052004

2012 (6)

2011 (1)

2008 (1)

2007 (4)

2006 (20)

2005 (13)

2004 (1)

Plugin by Oliver Schlöbe
[/apache]
[apache]

2012201120072006

2012 (4)

2011 (1)

2007 (4)

2006 (2)

Plugin by Oliver Schlöbe
[/apache]
[apache]

2012201120082007200620052004

2012 (6)

2011 (1)

2008 (1)

2007 (4)

2006 (20)

2005 (13)

2004 (1)

Plugin by Oliver Schlöbe
[/apache]
[apache]

The post type "my_product" does not seem to be registered or available.[/apache]

Call the simpleYearlyArchive function like so:
[php]simpleYearlyArchive('type', 'ExcludeCategoryIDs', 'DateFormat');[/php]
Some examples follow - each is a proper invocation of the plugin:
[php]simpleYearlyArchive();[/php]
[php]simpleYearlyArchive('','1');[/php]
[php]simpleYearlyArchive('yearly','4,7,9');[/php]
[php]simpleYearlyArchive('yearly_act','');[/php]
[php]simpleYearlyArchive('yearly_past','1,2');[/php]
[php]simpleYearlyArchive('yearly_past','','1,2');[/php]
[php]simpleYearlyArchive('yearly','','', 'my_product');[/php]
Parameter options are like following:

  • type (defaults to 'yearly'):
    - yearly: Displays a year-based list (Default). Can be empty aswell.
    - yearly_act: Only posts from the current year are displayed.
    - yearly_past: Only posts from the past years are displayed.
    - "date of year": Only posts from the given year are displayed.
  • ExcludeCategoryIDs:
    - A comma-separated list of category IDs you want to exclude.
  • IncludeCategoryIDs:
    - A comma-separated list of category IDs you want to include.
  • PostType (defaults to 'post'):
    - A registered post type to show.
  • DateFormat:
    - The date format string, according to http://php.net/strftime.

In order to run your blog proper and clean code, it's highly recommended to check if a plugin exists before calling it. If the plugin is not activated, it will "break" the theme and it may report errors or fail to load. It is therefore imperative to prevent the plugin from being detected in case it is turned off:
[php]if (function_exists('simpleYearlyArchive')) {
simpleYearlyArchive('yearly','4,7,9');
}[/php]

Options menu

There are a couple of options in the Simple Yearly Archive options menu.

  • Date format:
    The date output be customized. Check http://php.net/strftime for date formatting.
  • Seperator between date and post title:
    The seperator is displayed between the date and the post title.
  • Linked years?:
    Wanna have the years linked?
  • Before / After (Year headline):
    HTML tags, that will be inserted before and after the date headlines.
  • Show post count for each year?:
    Show the total post count behind for each year?
  • Show comments count for each post?:
    Show comments count behind each post?
  • Show categories after each post?:
    Show categories behind each post? The output can be styled with the CSS class sya_categories.
  • Show optional Excerpt (if available)?:
    Show the optional excerpt below each post title, if available?
  • Max. chars of Excerpt (0 for default):
    How much chars of the excerpt to show? Enter 0 to show the entire excerpt.
  • Indentation of Excerpt (in px):
    How much pixels the excerpt should be indented.
  • Link back to my website in plugin footer?:
    Consider linking back to my homepage in the plugin's footer.

 

530 Responses

  1. Hi ! Thanks for this useful plugin.
    This shortcode with include categories don’t run :
    [SimpleYearlyArchive type="yearly" include="60,52" order="DESC"]
    but
    This shortcode without categories run correctly :
    [SimpleYearlyArchive type="yearly"]

    In the shortcode above 60 and 52 are categories IDs. Isn’t it ?

    I don’t understand.
    My blog is running under WordPress 3.3.1
    Simple Yearly Archvie Version 1.4.3

    • Do you get any errors? I’m not sure the plugin still works with WordPress 3.3.1. We’re at 3.6 already. ;)

  2. Thank you for your reply.
    The reason of the problem was a conflit with settings of an other plugin (Advanced Category Excluder Widgets). This is my fault …
    In fact, there is non problem with WordPress 3.3.1. But I upgraded it , by the way.
    :)

  3. The updated plugin started showing both drafts and private posts in my archives, which freaked me out. When I updated it again, it stopped working. When I call the shortcode listed above it breaks the theme. What happened to this perfect plugin? :(

  4. Hey,

    well, if you’re okay with sending me a login to your WP site so I could see myself, that’d make things a lot easier for me to check. :) If you’re okay with it, please send the credentials to scripts (at) schloebe (dot) de

  5. Hi Oliver, thank you so much for the great plugin but I have two questions:

    1.- The first question and the more important is that when I install SimpleYearlyArchive Plugin, enter in conflict with Top Commentators Widget Plugin, SimpleYearlyArchive Plugin working perfect but Top Commentators Widget Plugin stop working.

    2.- How I do a page with SimpleYearlyArchive Plugin for the catgories?

    Here my link archives: http://www.getafevoz.es/archivos/

    Thank you Oliver :)

    • Hey there,

      regarding your 2nd question, see the section “Implementation / Usage” up on this page.

      • Hi Oliver, and the first question please? you have a posible solution?

        My second question is because when I see the section “Implementation / Usage” I not see nothing of catgories, sorry and thanks.

        • Hey,

          just tested the Top Commentators Widget Plugin while Simple Yearly Archive was activated, and both plugins work just fine for me. Maybe another plugin is causing the issues?

          Regarding your second question. Use this code:

          [SimpleYearlyArchive type="yearly" exclude="x"]

          where x is the ID of the category you don’t want to show.

  6. Pingback: Die besten Wordpress Plugins 2013 - Nicht nur für SEO!

  7. Hi,

    Great plugin! I have a question? Can I define what a year means?
    For example I want to archive posts from september 2013 to August 2014 and so on….like a school year.

    Thanks in advance

      • Hi Oliver,

        Thanks for your reply Oliver! Is there a quick fix on your code, where i could possibly change what you retrieve as results? For example instead of if year = XXX to get results between september and august or something like that? Is there a fast work around?

        • Well, as you can see here http://www.schloebe.de/archiv/ the list is separated by year… what’d be the seperator if you choose to use results between september and august? That’d pretty much be a monthly archive, so I’m sorry to say there’s no quick workaround I can think of.

  8. Hi Oliver,

    thank you for this great plug-in.
    It works very well and it looks as simple and great as I could wish for!

    One question:
    Is there a maximum number of posts the plug-in can handle?
    Right now, there are 646 posts altogether and most of them are in the archive. The archive is not shown when the shortcode is included in its basic version.
    But it is shown, when “yearly_past” is added.

    This is the site: http://www.berlinkonzerte.de/archiv/

    Thank you for your kind attention!
    Ben

          • Hi Oliver,

            thanks for your reply (I cannot answer to your last reply so this is why I answer here).

            Regarding your question:
            Yes, the plug-in is called on the page, it is just the amount of posts that is different between the two versions I sent you. Everything else is the same.

            - on the site /ACHIV I use “[SimpleYearlyArchive type="yearly_past"]”
            - on the site /TEST I use “[SimpleYearlyArchive]”

            So I am still pretty sure that your initial thought, a memory limit, is the reason for the problem.

            Is there a possibility to increase the maximum number of posts (=the memory limit you were mentioning before) the plug-in can handle?

            If that is not possible: how could I leave out only posts from earlier years? (type=”…”)

            Maybe I can send you the log-in data so that you can take a look?

            Sorry for bothering you again, your help is appreciated a lot!

            Thank you!
            Benedikt

  9. Hi, thanks but I encounter the following Notice: Undefined variable: listyears in /home/…/public_html/…/wp-content/plugins/simple-yearly-archive/simple-yearly-archive.php on line 251

    When using exclude/include parameter, only

    Any idea how to fix it?

  10. Really thank to you Oliver for this quick reply and ;-) upgrade

    but for now there is the following notice
    Notice: Undefined variable: listyears in /home/…/public_html/…/wp-content/plugins/simple-yearly-archive/simple-yearly-archive.php on line 277

    I’m using [ SimpleYearlyArchive include="23" ] for example, then in fact 1rst year list is right, but next there are posts of these 2 years, it should show only posts of 2d year, etc

    Good luck

  11. Hi, thanks for the awesome plugin. I have a little problem with it. When I click on the year then it expands my news list, I choose the news and go to read it and now if I go back to the news list (just going back) then the news are not expanded anymore and I have to click again on the year number. How to change that so, that if I come back from reading then the news list are still expanded?

    • I know it can be kinda cumbersome, but I’m intending the plugin to be as lightweight as possible. Most people open links with their middle mouse button anways, which opens links in a new tab/window, so when they close the new tab, they’re on the archive page again. :)

  12. Hello!

    I’ve used this plugin for several years on a site I manage. Now I’m relaunching the site—building from scratch—and hoped to continue using it. But when I paste the shortcode into a page, not only does it not display the archive, but it also removes my footer and sidebar. I disabled the other three plugins I’m using and it didn’t help. Any ideas? I’ve upgraded to the latest release of both the plugin and WordPress.

    Thanks!

  13. Hello Olivier, thanks a lot for your plugin. I have just started to use it today and it seems like i have a problem. The plugin is not showing all of my post just the ones that apparently have a certain category (its in spanish but for example the plugin is just showing the post that have the “Documents” category). I have created a static page and im using this shortcode : [ SimpleYearlyArchive].

    I will really appreciate your help.

    • It should be showing all your posts if you don’t have a parameter given in the shortcode. May you please give me a link?

  14. I can’t get any exerpt to show only title. I use WordPress 3.8 and theme Twenty Thirteen. Nice plugin!

    • The plugin lists the post titles by default, no need to enable excerpts display. Or what do you mean?

      • I mean that it would be nice to see short exerpt in a list below every title. I thought that is possible because you have an option for that in a settings page.

        • Hey Juha, if a post does have an excerpt, it will be listed. Check if your posts have excerpts.

  15. Two things:

    1. Does it support pagination? Or is everything displayed on one page?

    2. Is it possible to include the first attached photo of each post as a thumbnail?

    Thank you.

    • Hi Mathew,

      1.) No, a single-page archive will be generated.

      2.) Well, I’m not sure if this would break the clean nature of the plugin. What do you think?

  16. i need post date sunday 27th and want to archive posts from september 2013 to August 2014 on years please help me for that thing
    that plugins help for me

  17. Hi Oliver,

    great and easy to use plugin. Thanks. One question: is it possible to add custom post type articles to the archive?

        • Hey Steffen, would be possible but isn’t creating post types aiming to separate posts from the normal ones? Why list the normal posts along with the custom post type posts? Wouldn’t categories be better for that matter?

          • Thanks Oliver for your answer. I was pretty sure to do sth good. But you are right. Everything can also be done in categories instead of custom post types. So I could solve this this way. Thank you.

  18. Pingback: Duplicate content on WordPress – hey, Google indexed my tag pages!

  19. Hallo Herr Schlöbe,
    erst mal vielen Dank für das tolle Plugin. Ich hätte einen erweiterungsvorschlag für das Design. Leider weiss ich nicht wie ich dies lösen könnte.
    Ich würde gerne alles im jquery oder jquerymobile style anzeigen.
    Anbei ein Link zu einer Demo wie ich mir das vorstelle, jedoch natürlich ohne funktion.
    Vieleicht könnten sie dies in ein Update einbringen oder vieleicht mir sagen wie ich es lösen könnte.
    Nochmals vielen Dank
    Gruss
    Richard
    http://www.mv-lutzenberg.ch/test/

  20. Hallo Richard,

    es bedarf sicherlich einiges an CSS-Knowhow, aber dieses Layout lässt sich jetzt schon mit CSS umsetzen. Jedes Element meines Plugins hat spezifische CSS-Klassen und -IDs, die man dafür ansprechen und nutzen könnte. :)

    • Guten Abend Oliver,
      vielen Dank für die rückantwort. So wie es tönt konnte ich dich nicht für ein grösseres Style-Update begeistern und überzeugen ;-) Leider habe ich kein wissen in css und bis ich dies gelernt habe sind wir bei WP version 10 angekommen :-)
      Ich lass mich mal überraschen, vielleicht gibt es ja noch Heinzelmännchen oder ein tolles Oster-Weihnachtsgeschenk
      Gruss
      Richard

      • Das Problem ist, dass ich das Design nicht vorgeben kann, da jedes WordPress Layout anders ist. Bei dir mag das Aussehen wie bei jQuery Mobile passend aussehen, aber bei einem anderen Theme würde das vllt. seltsam aussehen. Deswegen kann ich nur die Mittel mit den Weg geben, damit sich jeder die Ausgabe des Archivs seinem Desihn anpassen kann. ;)

        • acho ist das…
          kannst du mir evt noch einen hinweis geben mit welchen dateien ich mich da beschäftigen muss. Nur mit der css datei oder auch mit den allgemeinen php dateien deines Plugins?
          Nochmals vielen dank für deine bemühungen

          • Nur mit der CSS-Datei deines Themes (style.css). Die erforderlichen CSS-Klassen bringt mein Plugin von alleine mit.

  21. Hallöchen,
    Das Archiv als Seite sieht ja ganz gut aus… Aber kriege ich das ganze auch irgendwie in einem Widget untergebracht, quasi als Ersatz für das normale Monatsarchiv-Widget in der Sidebar? Oder wäre dafür ein weiteres / anderes Plugin nötig?

    (kann gut sein, dass ich mal wieder den Wald vor Bäumen nicht sehe…)

    • Hallo Rafael, ein Widget gibt es nicht. Allerdings gibt es einen kleinen Trick:

      1.) In der functions.php deines Themes folgende Zeile einfügen:

      add_filter('widget_text', 'do_shortcode');

      2.) Ein Text-Widget erstellen und dann einen Shortcode des Simple Yearly Archives eintragen, z.B.

      [SimpleYearlyArchive]
  22. Mark Louie EspedidoApril 9, 2014 at 11:47 am

    Just the plugin that we need! Is there a way to pull and sort by date from a custom field?

Leave a Comment