Support » Themes and Templates » category tempaltes=different themes for different cats?

  • As mentioned above, does using the category template () actually allow you to change the theme for each category?

    I read on one of the threads using different themes for different cats is not directly possible, so I quickly threw in a hack using if statements (ie. if cat=xxx, use theme-xxx), but this is really inefficient as the html structure must be the same for all pages and in what I did, all three themes used where more like sub-themes under the main theme.

Viewing 2 replies - 1 through 2 (of 2 total)
  • if you create a file in your theme called ‘category-$id.php’ then it will be applied to only the category with the id of $id (i.e. whatever the categories id is).

    If you want a totally different theme for that category, then you can just make that one file be completely different from the rest of the files in your theme. The complicated part is that you’ll have to make sure that all the included files (like sidebar, header) are either all in that one file (category-28.php), or that the file includes special versions of those includes (so you’d have to rename them sidebar-28.php or something). You’ll also have to include a different CSS file etc.

    Hmmm.. rereading your quesetion, if the HTML is always the same, then do you mean that it’s only the CSS that changes? In that case you could have the if statements in ONLY the header where the CSS gets loaded. Alternately, you can make special versions of the header and use the category-28.php trick above to load different versions of the header for the special categories.

    With category templates you can create pages for categories as different as you want. Sticking to the default files like header.php etc. may be difficult because the HTML must fit in each template.

    But you don’t need to split things up that way. I’ve created 3 category pages on my site which each output complete HTML pages. One category for normal blog posts including a linklog on the side, one for a photo log with one photo per page and a category for one specific topic with some different styling.

    I did create some reusable parts like a comment form.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘category tempaltes=different themes for different cats?’ is closed to new replies.