Support » Themes and Templates » Can each category page have its own look?

  • Okay, I’ve almost given up looking for an answer to this, but thought I’d try to explain myself better one more time.

    At the moment, my category pages look like my index page.

    But what I would like to do is have different content in each category sidebar for example and a different header image.

    Is what I’d like to do possible? And by that I mean possible for a newbie? 🙂

    And if so where do I start? I don’t mind spending hours playing around to see what works, but need a few pointers. Or for someone to say that I can’t do that so go do something else instead.

Viewing 15 replies - 1 through 15 (of 19 total)
  • It’s possible. You could play a few tricks with CSS to replace the header image based on the category.

    Likewise with the sidebar, using custom CSS for each category, you could hide elements and display others.

    You’ll need to hack your template to add a “<category>.css”, where WP will be filling in the <category> part.

    joeking: I had the same question. Take a look at this thread and see if it helps:

    I still haven’t had my ‘permalinks’ question answered, so I haven’t started implementing it, yet.

    From looking through the code the other I seem to remember seeing that you can have a template in your theme for each category…such as category-***.php

    Many thanks for everyone’s help.

    I’m going to see what I can do and will let you know how I get on. Here’s hoping 🙂

    Okay, I’ve tried creating a very simple category-1.php file with just three lines:

    <?php get_header(); ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    This works because when I go through to category 1 I see just the header, sidebar and footer. So far so good.

    But I then created headercat1.php so that category 1 would have its own header.

    I changed category-1.php to:

    <?php get_headercat1(); ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    And the page doesn’t show 🙁

    Instead I get an error message saying :

    Fatal error: Call to undefined function: get_headercat1() in . . .

    Any ideas where I’m going wrong here?

    <?php get_header(); ?>

    Is a “tag” for WordPress’ PHP function get_header(), which does little more than provide an include to the header.php file of the current theme.

    <?php get_headercat1(); ?>

    Is a tag for a non-existent function, get_headercat1(), unless you’ve actually written it. Use instead the underlying functionality of the get_* include tags to include your new template:

    <?php load_template( TEMPLATEPATH . '/headercat1.php'); ?>

    Thanks very much Kafkaesqui.

    I assume I’ve to enter the template path where you’ve put TEMPLATEPATH in the code.

    My headercat1.php has been uploaded to the same theme folder as the category-1.php file.

    It’s full path is:


    I’ve tried variations of this without success.

    Am I doing the right thing?

    Have You tried just doing it literally? I’d assume the big letters means a code that wp uses, the templatepath being known otherwise by wp, eg when you select the theme.

    try it the way it stands!

    “I assume I’ve to enter the template path where you’ve put TEMPLATEPATH in the code.”

    You can, but TEMPLATEPATH is defined as a constant (a *permanent* PHP variable) in WordPress; so when you use it in your code, it will insert the full path to the current template/theme directory.

    Kaf – Doh! I’m so stupid. It just seemed too obvious to copy the code you gave me.

    Superkim and Kaf – many thanks for your help!

    I am now going to add other things to the page but am now on my way to creating individual category pages.

    Thanks to everyone who has helped me 🙂

    Okay my basic category-1.php has just this code:

    <?php load_template( TEMPLATEPATH . ‘/headercat1.php’); ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Now I need to have it display the posts for category 1, but don’t know what code to add for this to happen

    Also if there are say 20 posts in category 1 will the category 1 page display all 20 posts? What happens if you have 200? And if it doesn’t display them all, where do people find them?

    Okay, I had help from MDAWaffe who saved my life with this one. Check out the discussion at and this is brilliant. Totally brilliant and amazingly easy.

    Basically, you can take the archives.php (unless you already have a category.php from your theme author) and make a copy of it and call it “category-1.php”. You can add your own text, do your own thing to it and it is the category page for category one. If you have a category 24 it would be “category-24.php” and you can do your own thing…etc.

    When WordPress looks for the category page when you click a category, by default it looks for (if I remember right):

    1. category-X.php
    2. category.php
    3. index.php

    Read the discussion then look for his article on the Codex when it is back up running as it goes into a little more detail. It’s brilliant if you are serious about having customized categories that still use all the loverlies of the WordPress Loop.

    hey joe, you get this to work?

    i want to do the same thing pretty much but I cant get it to work.

    Bob – yes to a degree I have but am having a few problems with content. The actual creation of category-1.php, etc., is very easy. WordPress just picks up on it instantly and brings up the correct posts without you having to do anything else.

    My problem is I want a third column and have resorted to tables (I know – but I don’t understand enough CSS yet) to do this. The correct content still displays but the style sheet is gone so headers, text, etc., are all the same size and font.

    But if you are not wanting to make major changes, just copy a file such as index.php and rename it category-1.php. Make a change, upload it and WordPress will display it as the new category 1 page.

    ok, here is my problem – i got the category pages to work:

    but when i click to one of the full stories (in this case in the third category):

    I lose the formatting of the category – why is that? and if another template applies here can i create files similar to category-1,2,3.php. It looks like archive.php may be controlling this so can I create archive-1.php, archive-2.pho, etc. This seems a long way around solution – why wouldnt the category templates cover everything posted within them?

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Can each category page have its own look?’ is closed to new replies.