I recently was tasked with converting a Tumblr blog into WordPress. On Tumblr, or at least on the theme I was dealing with, they have a pretty fancy archive section that lists all the posts as images underneath the months. If there aren’t images, then it shows a little text. To do something similar, I used the Snazzy Archives plugin.

My posts were using WordPress galleries, so the images were attached to the post, but not in the content as IMG tags. The Snazzy Archives plugin pulls an image it finds in the content. So, I created a new layout which defaults to pulling the first image attachment instead.

The documentation may not be clear on this: you can create a new layout by duplicating the layout PHP and giving it the next number in the sequence. There was an existing snazzy-layout-2.php in the plugin folder, and I created a snazzy-layout-3.php. After it was uploaded, the third layout option then appeared in the plugin’s options page in the WordPress admin.

The Code: snazzy-layout-3.php

This layout pulls in the first image attachment on the post instead. If it does not find one, then it falls back to the default functionality of looking for an image in the content or using excerpt text. I also added a link around the image. You can also Download the php layout file here (txt file).

A Little Extra Snazzy

The default styles seemed to have very little margin between the columns, and I wanted to have a hover state on the image. So I added this CSS to my stylesheet:

/* ---- Snazzy Archives ---- */
article .sz_cont { width: 140px; }
article .sz_month { margin-right: 12px; }
article .snazzy-image:hover { opacity: 0.75; }

Further Reference:

Comments on this Article

  1. Janet Siefert says:

    I have used the Snazzy Archives for a while. But recently it has ‘quit’ archiving the posts. If I uncheck the snazzy cache, it works just without the thumbnails. I like the thumbnails.

    You have any suggestions as to what might be the issue?

    http://pineknotfarmandlab.com/archives/

    • Josh says:

      I’m not sure what the issue might be. You may want to check with the plugin author. The plugin was just updated on the same day you posted (2013-3-12). It also looks like one of the newer updates added “Support for Featured images”, which may replace what I originally posted about.

Comments are closed.