Adjacent Archive Links for WordPress

WordPress logoEver since I adopted the current design for my monthly archive pages (one that lists all my posts for that month by title, rather than paginated excerpts—Matt blogged about this approach back in the day), I’ve wanted a convenient way to page back and forth through my archives by month—without having to blindly hard-code links for $current_month−1 and $current_month+1. I discovered a few people asking for the same thing, and I found an out-of-date plugin that had attempted to accomplish it, so I decided to write my own from scratch, as part of my recent redesign. Here’s how it looks in context:

Screenshot of adjacent archive links
Screenshot of Adjacent Archive Links


  1. Download Adjacent Archive Links v3.0 from the Plugin Directory (or from me here)
  2. Unzip the file and upload the folder adjacent-archive-links to your /wp-content/plugins directory
  3. Activate the plugin
  4. Add the new template tags (described below) to the appropriate template file for your theme (e.g. archive.php)

After activating the plugin, you will have two new template tags at your disposal:

<?php previous_archive_link( 'format', 'link' ); ?>
<?php next_archive_link( 'format', 'link' ); ?>

They adapt their output depending on whether the date archive is a day, a month, or a year, and they will only output a link for the previous/next-most time period in which there is a published post. If there are none, it will output nothing. Both tags take the following two parameters (which were based on the core WordPress template tags: previous_post_link and next_post_link):

(string) The format parameter defines what comes before and after the link. In the string, %link will be replaced with whatever is declared in the link parameter below. previous_archive_link defaults to &laquo; %link and next_archive_link defaults to %link &raquo;.
(string) The link parameter controls the link text. Both tags default to %date, the adjacent archive page’s localized date.

Questions, comments, and suggestions are always welcome. If you’re interested in contributing to the code behind Adjacent Archive Links, it’s hosted on GitHub.

Update: Plugin en el español por Andrew de WebHostingHub.

Feel free to if you found this useful.