Archive for the ‘Tutorials’ tag

A Better WordPress Monthly Archives

If there’s one big problem with WordPress (and blogs in general) it’s that posts come and go very quickly. This is great for people who are embarrassed by what they’re writing, but for the average person this can be a great disappointment.

It also doesn’t help the case that WordPress’s default Archives page is ugly and hard to use. Nor that most free themes that contain an Archives page aren’t much better.

WordPress Default Archives

Since you may be a little confused, dear reader, some visuals. The default WordPress archives page (that’s archives.php for those keeping score at home) is pictured at right (click for bigger).

Anyone who’s ever used it will know that they’re taken from the monthly link to pages that simply show all entries from that month in full form (this time we’re talking about archive.php sportsfans). The format and contents of those pages doesn’t concern us now, as it’s a long-standing — even if unwise — tradition that clicking “February 2007” on the blog of anyone mildly prolific is a dangerous idea.

If you look very hard at improving the Archives page in WordPress, you’ll quickly come to understand why they tend to be so sub-par. WordPress’s native function to create archives (wp_get_archives) is frighteningly limited in it’s abilities. I’ll spare you the details, but suffice it to say that nothing it outputs is much better than what we’ve seen.

Since WordPress itself fails, a different application is needed. Having already found Justin Blanton’s Smart Archives plugin — which I used to make my archives at Frozen Toothpaste more presentable — I decided that was a good place to start.

Frozen Toothpaste Archives

As the Frozen Toothpaste archive shows (see left), the Smart Archive plugin allows you to cleanly display all the your writings from a given month listed chronologically. This, I decided, was the Archives page I wanted my themes to have.

But requiring plugins for a theme to work is fraught with problems. It requires more work than the average WordPress user can or wants to commit to. So however I made my archive, it had to be inside the theme. The easiest way to do that: include the plugin on the page that creates the archives — archives.php.

Though I’m neither a PHP or server-load “pro,” I couldn’t find much of a downside to to putting the code from the plug-in on the page (if you are such a person and can tell me that there is a problem, please do). And, better still, doing so would make the creation of a nice monthly archive as easy as the creation of a default poor one.

Carter’s Line Achive

So essentially, that’s what I did. I did do a great deal of shrinking and modifying of Mr. Blanton’s plugin, but it meat of it is still intact. Most of my cuts were becuase I required it to do far less than the plugin can. I wanted the code as lean as it could be while still providing the necessary function, which I think it does. To see my archives.php page it in action, just head over to the Ikiru Demo Blog and look at it on any of my themes. (You can also see the Archives page on WordPress’s default theme for comparison.)

And if you’re looking for something even more fancy than the Archives pages provided by Smart Archives (in or outside of) my themes, I’d suggest that the best place to look is Clean Archives which is both flashier and larger than the Smart Archives plug-in. Though these characteristic were detrimental to my need here, they may be exactly what you’re looking for.

One Theme at a Time

This is more a note to myself than anything else, but I bet some other aspiring WordPress theme designer will make the same error sometime, so it’s becoming a short tutorial.

OK, so here are the steps you should follow:

  1. Make one WordPress theme. Be completely satisfied that nothing is missing from it and nothing is superfluous. Then move on to another theme.

And you’re done. Pretty neat, huh?

If you’re wondering why I feel the need to make a tutorial for something so obvious, consider my process:

  1. Make one WordPress theme (BWO). Get it to OK, but fail to add all that’s necessary and remove all that is not.
  2. Make a theme that’s based on the original (BWO_doodle).
  3. Revise original theme by adding some things it was missing.
  4. Make more themes based on the original, in my case four: BWO_one, BWO_space, BWO_invert, Carter’s Line.
  5. Revise original theme, improving search.php and archives.php; removing the unused and unnecessary files (comment-popup.php, attachment.php, links.php).
  6. Realize that these changes are important enough to by made in all previous version of the theme.
  7. Spend far too much time making those changes to the previous versions.
  8. Write a tutorial (another waste of time) about your foolishness.

I should also be clear that this is a (slight) oversimplification of the process. It glosses over the large number of alterations (usually but not always to the stylesheet) that’s I’ve had to make as well.

I guess this is probably part of the learning process, but it’s making me feel completely silly.