• Resolved jdsnia

    (@jdsnia)


    I’d like for single posts in different categories to use different templates. For example, if someone is looking at a post in the category “movies,” I’d like for it to have a different template than if they were looking at a post in the category “books.”

    I can make the relevant posts pages and manually select a different theme for each one, but that seems… like a terrible solution. Any way to do this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Sure. You simply specify each category template. So if movies is cat id 5, then create a template category-5.php, books is cat id 7, so it’s template would be category-7.php, etc.
    http://codex.wordpress.org/Template_Hierarchy
    http://codex.wordpress.org/Category_Templates

    Well, for single posts the category templates won’t work, but you can try this plugin:
    http://guff.szub.net/2005/07/21/post-templates-by-category/
    (and there is also a similar one mentioned on that site – the inheritor)

    you could go and hack up the appropriate php and template files, then create css classes/id’s for each category, it would require a little work upfront, but would probably be the cleanest and most efficiant solution in terms of server overhead. I have one site which i’m converting to wordpress from “semi-static” content, and it’s separated by topic, i’m more or less just creating categories, then classes/id’s in the css and php to maintain the current look and feel of the site which is a bit different in each topic area.

    chradil,
    the average user doesn’t hack files – they simply don’t know how to do it, so “advices” like that are completely useless. Sorry.
    The solution I’ve posted does exactly what the OP was asking for and without any hackery. One just has to create the templates and call them through the plugin. (How to style those templates, i.e. classes/ids and their css definiton – is up to the user.)

    moshu, good catch, I didn’t see the “single post”.

    Sorry jdsnia

    moshu, I understand the abilities of the “average” user are sometimes limited. and “hack up the appropriate files” was a bit of an overstatement. I’m familiar with the plugin you’ve suggested, and it just seemed to me that since with the plugin the user would still need to create all of the css needed for each category anyway, adding a couple of lines and changing a few css classes in “single.php” would be alot easier than the process of creating the templates. plus would be easier on the server, etc should the site become popular.

    Thread Starter jdsnia

    (@jdsnia)

    Thanks guys. Both suggestions were helpful, and good things to know.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Separate templates for single posts’ is closed to new replies.