Unique Templates for Different Categories and Authors in WordPress

Alphabet stencil

I recently had occasion to want the archive templates for two categories to look different. I must admit that upon thinking about it, this can’t come up too often, but I was working on a client’s website and he has a News category, where he can post updates about Mercedes-Benz (he is a sales representative at Mercedes-Benz of Tampa) and he also has a Feedback category, where people can leave feedback on his site, which are turned into posts in the feedback category, that people can then read.

In this instance, I wanted to put a little extra text at the top of the feedback category, saying that the feedback was left by clients of Simon and you are welcome to leave feedback of your own using the feedback form.

Category Slugs

The slug is listed next to each category

So I did a little research and found that this need is supported natively by WordPress and is very easy to implement. Using FTP, go in to your active theme files (normally located under wp-content/themes/themename/) and you will likely find either category.php or archive.php. Assuming you want to work from the category template you already have, make a copy of the file and call it category-slug.php, where slug is the category slug. If you’re not sure what the slug is, go to your Categories menu under the Posts menu and you’ll be able to see the slug of the category you want to modify. Make sure that you keep the file in your active theme’s directory (where you found the original category.php/archive.php).

Now you can edit this new file to achieve the modifications you’re looking to make (see How To Edit Your Theme Files). In my case, it was placing some text before the list of posts and removing the comments call (as the posts in this category are not open to comments).

A similar method can be used for creating unique author pages. You just need to copy author.php and rename it author-ID.php where ID is the author ID. There is more information on how exactly this works for categories and authors in the Codex.

4 thoughts on “Unique Templates for Different Categories and Authors in WordPress”

  1. Ishan says:

    Good tip.
    However, any idea if this will work with frameworks like Thesis?

    1. Dave says:

      I’m sorry Ishan. This comment seems to have slipped through without me noticing and replying to it somehow.

      I’ve never used Thesis, so I’m not sure how it works. However, if the Thesis themes use either category.php or archive.php to show archives and generally follow the WordPress file structure, I don’t see why this shouldn’t work.

  2. Dana says:

    When I found the title, I think that’s what I need but not right. My idea that looking for a template to change for one unique category that different with the main one.

    1. It sounds like what you’re wanting to do is exactly what this tutorial is about. You can have a particular category show up differently from all the other ones by copying category.php (or archive.php if that doesn’t exist) and rename it to category-ID.php, where ID is the category ID. Does this make sense?

Leave a Reply