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.7+

  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:

Some examples follow - each is a proper invocation of the plugin:

Call the simpleYearlyArchive function like so:

Some examples follow - each is a proper invocation of the plugin:

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.
    "<unixtime-from>-<unixtime-to>": Only posts from the given (unix)time period 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:

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.

 

747 Responses

  1. Same question as before:
    How do I get to display the archive as in your demo.
    2017 (67)
    2016 (19)
    2015 (12)

    Please help me with this!

  2. Expat Gone ForeignJune 2, 2018 at 8:36 pm

    Hi Oliver,

    Thanks for this plugin! I have a quick question:

    My page now displays the archives like this:

    2018
    2017
    2016
    and so on.

    When I quick on a specific year, for instance 2018, X number of posts are displayed under 2018.

    My question is if there’s any way to display every posts under every year without having to click on each year. I’d like visitors to click on the page where I have the archive and already be able to see each posts under each year without having to click on them.

    Is that possible?

    Thanks!

  3. So is there a way to make it so that it will limit the list to a user defined period based on the current time? Like only posts from the past week or month? Or perhaps limit the total number of posts, like only displaying the last 200 posts? Thanks.

    • As for limiting the list by time period please take a look at the “Implementation / Usage” section on this page, specifically the “type” parameter.

      As for limiting the output to e.g. 200 posts just add the following code to the end of your theme’s functions.php file:

      add_filter( 'sya_get_posts', function() {
          return array(
              'numberposts' => 200
          );
      });
      • Thank you so much! That last bit to limit by number of posts worked like a charm! Thank you so much for such a wonderful plugin!

  4. Hi Oliver

    (I thought I asked this a couple of weeks ago, but cannot find the post now. Maybe I posted somewhere else or made another mistake. Hope I didn’t offend you in some way and it got deleted. Anyway, I’ll try again)

    Because the digits in the font I use have different widths, I cannot find a way of getting the first character of my titles to line up perfect vertically in the archive list. Can you suggest a way of achieving this with the current release? If not, would you kindly consider some feature to allow this in a future release?

    Many thanks

    Steve

Leave a Comment

mattis Nullam nec efficitur. ut tempus libero Curabitur odio eleifend dictum