Support » Themes and Templates » Working Category Templates!

  • Hey all!
    I don’t have a ‘theme’ to release, yet. Not sure if I’ll have time to do that for a while. But, I wanted to show off the working ‘category templates’ on my site.

    After many questions and lots of reading through the codex, I compiled much of what I heard and read and finally figured it out. Thanks to everyone who gave me some tips and leads.

    Moshu – If you still want the code on how to set this up, let me know. I can send you the code.

    So far, I’m only doing 5 of the 9 categories (that I’ll have) with new templates. The rest will use the default.

    That’s it! Just sharing! 🙂

Viewing 15 replies - 1 through 15 (of 16 total)
  • Wow that is so cool. How you do that? Can it be done with 3 colums

    it’s quite easy once you know how:)

    hayscg it can be done with any number of columns, with as many categories as you want, and you can have a vastly different style for each one. Do as jberlund has done, as well as others, and read up on the articles and in this forum for relevant questions. It’s been one of the most requested features – it works, but it also takes work to make it work – well, that is it takes time depending on how deep and extensive you want changes. I guess only your imagination is the limitation.

    FOr example, for the category film you can have a site that is completely different to one on , say, Farms. Each can be unique in design.

    The header is used for the php and style sheet calls on this design. (based off the Kubrick files). So, yes, it can be done with 3 column layouts, too.

    I was trying to work through some of the options with Moshu last week, which gave me more insight into what I needed to do. Check out the thread here:

    One of the COOL parts about doing the categories this way (though, some may not like it) is that my main page now becomes an almost dyamic layout. Every new post I make, the main page changes with the category I give the current post. 🙂

    So, one day my main page will have my general template up. A few hours later, if I post a home remodeling entry, THAT template takes over. I love it!

    Let me rephrase that first paragraph:
    The ‘header.php’ file has the code for the style sheet and the php to ‘change’ the templates per category.

    That’s great. I’m most impressed that u did this with cats, not pages.

    Thanks! It’s nice to finally feel like I’m giving something back to the board, instead of just asking for help. 🙂

    Just a note, the following is a brainstorm session more than a solution. Hopefully it will lead to some feedback and a possible solution in the future.

    It seems to me that there should be a way to put the category check higher up, before the theme is selected. As I understand it, currently, the wp-blog-header.php file is responsible for delegating down to the theme’s files for a given request. If that request is for a category, then the theme’s category php file is loaded (using the standard rules: category-X.php then category.php, etc.).

    It seems that that function get_category_template() would be the proper location for this check to happen. Currently, it uses the TEMPLATEPATH variable to check for the existence of and return the appropriate php file to include. If we could refactor that part of the code so that a new function, get_template_path was called to determine the template path, then the entire theme could be modified on a per-category basis.

    There appears to already be a get_template_directory function that will do what we want it to do. We just need to parameterize it so that it can vary its return value based on a category id (or any other aribitrary information, for that matter). The problem, as I see it, then becomes 1) replacing all occurances of TEMPLATEPATH with a more dynamic call and 2) ensuring that any sibling HTTP requests get the same template. For example, if the specialized category page requests a themed image, that the image is requested with the appropriate theme, as well. Number one seems rather easy, while two could get hairy as there are numerous places where external links and files may be requested and need to be kept in proper order.

    Any ideas for how to accomplish that would be most appreciated as this is something I’m looking to do with my site.



    jberglund: Isn’t this fun.

    I also fell in love with this and have been using it on my site for a couple months, thanks to the handy folks here who helped me figure it out. My shifts and changes are much more subtle, but they do the job they are intended to do.

    Great work.

    I did notice however that your sidebar is messed up at the meta section and below – the site is too pretty to have a little boo boo. I think it’s a missing div or li – easy fix.

    Really wonderful stuff!

    Thanks, Lorelle. I appreciate the feedback!

    Yes. It DOES feel good to accomplish stuff like this. I love a good puzzle. I love it even more when I solve it the way I want! 🙂

    Hmm… that’s odd. My Meta section looks fine on my screen. What browser/platform are you running? I’m looking at mine with IE on a PC platform. Maybe it’s a browser discrepancy. (I still need to download Firefox and a couple others for testing purposes).

    Let me know and I’ll do further checking. Thanks again! 🙂

    I noticed it in FF – download it and install the Web Development add on and you will NEVER turn back. Honest. I waited too long and wish I’d had it years ago.

    I’ll do it today! Thanks! 🙂


    I see what you mean about the Meta info being out of whack. Any thoughts as to a fix for it? Looks perfect in IE. I’m surprised it’s so off-kilter in FF.


    I was away last week – no computer, no internet 🙂
    I am really glad you succeeded. Great job!

    The reason for the meta being kicked out is because the calendar isn’t included as part of the list items of the menu…. it’s simply represented as a table in line…. try wrapping your call to the calendar with li tags….


    Thanks, TechGnome. I’ll give that a try.
    And, Moshu – Ugh! No Computer?! Brave soul!
    The code is on our other thread:

    Check it out and give it a try. Thanks again!

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Working Category Templates!’ is closed to new replies.