WordPress FAQ: How Do I Use Category Themes?

Is it possible to have different layouts, theme or links depending on the category the user has clicked?

This question comes from Milo Riano. Milo wants to be able to have what I call a “flexi-site”. A Flexi-site is a site that is flexible in terms of display options or layouts. This could really be an extension of the question about multiple blogs as well.

Template Files

The key here is in template file hierarchy. WordPress looks in the theme directory to find the following files, and in this order:

  • category-X.php
  • category.php
  • archive.php
  • index.php

So if you have a blog that you assign a category of “Linkblog” to, and you want the linkblog to be displayed in a different format that the rest of the blog, you could simply find the ID number of the category (We’ll call it 23 for the sake of argument), and you could create a special template file with the unique layout you wish to use, and call the file category-23.php. Now everytime the category page is loaded, the template file category-23.php will be used.

Custom CSS

You can take this approach a step farther through customized CSS stylesheets. As most templates use the inbuilt function

<php get_header() ?>

to summon the use of the common header.php file from the theme, it is also possible to create custom headers and include those directly.

However, the better solution to this, providing you don’t have a vast number of categories that you want to display different CSS files for, is to simply use the WordPress template tag


to figure out whether to display an alternate stylesheet.

if( is_category( 23 ) )
   <link rel="stylesheet" href="http://example.com/wp-content/theme/cat23.css" type="text/css" media="screen" />
   <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

You can get real creative with this instead choosing to use


to determine if extra CSS can be added after the main CSS thus overriding styles. There are quite a few options and you are limited only by your creativity.

If you have questions for this ongoing WordPress FAQ series, shoot me an email and let me know. By doing so, you’ll get a free link to your site.

WordPress FAQ: What's up with the Amazon Plugin with WP 2.1.x?

How do I use the new version of the Amazon plugin? It never brings up what I am looking for and its very annoying. I want to be able to use it the way it was before the WP upgrade.

This question comes from Shannon Nelson who is complaining about the new version of WP-Amazon. Many of the blogs at b5 are product based or have a strong connection to products and so the WP-Amazon plugin is a favorite among affiliate bloggers.

The problem is that the new version of WP-Amazon, though still beta, leaves a large chunk of the less technical population behind. Based on the plugin site, I’m confident that the issues will be resolved by the time this version comes out of beta, however until then we’re stuck with it. The stable version of the plugin does not work on any of the WP 2.1.x branch and the beta preview version is only compati ble with Firefox 2, Opera 9 and (I think) Safari. Internet Explorer users are the big losers here.

Stay tuned tot he plugin page for news on future releases and we’ll be proactively monitoring and upgrading here at b5media.

WordPress FAQ: How Do I combine Blogs?

This morning, one of our bloggers posted a question in our internal forum. She was seeking guidance on how to take a few (three) blogs and combine them. I provided three solutions for her and decided, in the process, that I would kick start my braindead blogging (lately) into a mini-series of WordPress FAQ questions. Feel free to email your question to me at aaron [at] b5media [dot] com.

The question is:

I’ve wanted to have a personal blog (and really collate my 3 personal blogger blogs into one) and I’m looking at WP but I don’t want to have the “*blog*.wordpress.com” attached. Can I do this with a free blog, or do I necessarily have to buy one?

There are three different possible solutions I see to your problem, Grace. Each one, naturally, has a different difficulty level based on your technical confidence. As is always the case, the most cmplicated solution will probably give you the most flexibility long term. In all three cases, you’re looking at having to use WordPress.com as a go between to bring Blogger blogs in, then export as WordPress-formatted XML file, then import into WordPress via the built in WordPress 2.1 importer (or use mine if you’re on 1.5 or 2.0).

Combine all three blogs into a homogenous blog

The first solution would be to simply import all your blogs into WordPress and get all your content into one place. In my experience and observation, this will give you a solid platform that is still easy to use while giving you some probable SEO benefits. It seems that search engines tend to like WordPress blogs more than Blogger blogs.

Difficulty Level: Easy
Pro: Simple WP install, simple maintenance, familiar WP usage.
Con: You concede the ability to separate out the blogs as individual entities within the blog.

Single Blog, Broken out by Category

This is a similar approach to the first. You essentially bring all your content into the new WordPress blog. However, this time, instead of just having a lump amount of posts, assign a category to each post from each blog (i.e. Blog1, Blog2, Blog3). In this way, you will be able to massage your template using WordPress’


tag to determine what gets shown on each page. While this does not directly preserve each blog (all the content is part of the single WordPress install), you can achieve the appearance of multiple blogs and have the ease of the single WordPress admin.

Difficulty Level: Intermediate
Pro: Simple WP install, single WordPress admin, template flexibility
Con: Blog content is still managed as a single group of posts separated only by category iearchies.

WordPress MU

WordPress MU is the multi blog format of WordPRess. It supports multiple blogs and multiple administrative bloggers. In essence, you can power all three of your blogs from one single install of MU. If you need the actual flexibility of actual separate blogs, this is probably the right choice for you. However, it does have significant drawbacks.

Difficulty: Hard
Pro: Extreme flex. Lots you can do, lots of added perks from standard WordPress. Probably good for blog network level stuff or when five or more blogs are being managed.
Con: MU is quite tricky to setup. It has made significant strides in recent months, but it is nowhere near as polished as WordPress itself. It also requires some digging in the WPMU forums to find answers to questions like how to make MU respond to top level domains (i.e. http://example.com as opposed to http://example.mysite.com). Also will require a degree of systems level knowledge and comfort.

Whatever you choose, I’m confident WordPress is the right choice for you. Obviously, we have a system here that sings along on individual WordPress installs and we have had great success.

What questions do you have? Email them to me. Keep them WordPress related. :-)