Seperate templates for WordPress categories


WordPress icon.

Here's something interesting. If you use WordPress you can assign separate templates for different categories; presumably I'm assuming (what a redundant few words) this also means you could give different categories different CSS styles too.

The WordPress Codex says you can define different templates in your current theme based on the ID of the category you want to customise. If it doesn't find a specific template for the category, it reverts back to the theme default.

For example, the Rubenerd Show category here has an ID of 277 (the unfortunate legacy of using categories as tags before WordPress has native tag support) which means if I wanted to create a custom theme template for it, I'd create a category-227.php file. Other categories don't have that ID, so they'd continue to use the basic category.php template.

My plan of merging all my blogs into this one while giving the appearance of separate sites seems to be a neverending story, but all the pieces seem to be falling into place. So far I've learned:

  • Each category can have its own RSS and Atom feeds
  • Categories can be selectively blocked from appearing in the master site and feeds
  • Using the this plugin and method the term /category/ can be hidden from URIs

I'm starting to think it may have been less work to just move my blog here to my Django system after all, but I guess I have the advantage in this case that someone else is maintaining the code. I've gone this far though I guess, so no point stopping now!

Author bio and support


Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person. Hi!

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite bespoke cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.