• I am using 1.5.2 and using the Relaxation theme. I would like to display a different header image based on the different category of post.

    I’ve reviewed all the codex pages and the support questions, but I’m still very lost. I also tried using the Categories template, but that didn’t work at all. I’m really confused!

    1) Do I need to create category.php, category-1.php, etc.? I don’t have any category.php pages so far. I really just want everything to look the same, except for the header image.

    2) I get the impression I need to use some sort of “if category-8, then header-8” code somewhere. But I’m not sure where this would go. Does it go in the index.php? Or header.php? Or style.css??

    Thanks for any help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • It’s something very close to this.
    In ‘header.php’, put this:

    <h1 id="header"
    class="<?php if(is_home()) echo('header1');
    elseif(is_category('beans') ) echo('header2');
    elseif(is_category('balloons') ) echo('header3');
    elseif(is_category('badgers') ) echo('header4');
    elseif(is_single()) echo('header5');
    elseif(is_page())echo('header6'); ?>">
    <a href="<?php bloginfo('url'); ?>">
    <?php bloginfo('name'); ?></a></h1>

    Then in your css:
    h1.header1 {
    background-image: url('home.jpg');
    background-repeat:no-repeat;
    height: 145px;
    }

    h1.header2 {
    background-image: url('beans.jpg');
    background-repeat:no-repeat;
    height: 145px;
    }

    You’ll need to adjust a couple of bits there, but that will get you a whole lot closer.

    Thread Starter eveums

    (@eveums)

    Podz, Thanks for the tips, they were SOOO helpful. With your help, I have the header-switch working on the category archive pages.

    However, on individual posts, no header shows up at all. What I would like is to have the corresponding header show up on the single post from that category.

    I’ve looked at single.php page in my theme (I assume that template controls single posts…?) and it calls the header.php in the same way that archive.php does. Is there a way to get the header-switch to work on a single post display? And if so, where do I put the code?

    THANKS A MILLION FOR ANY HELP!

    Thread Starter eveums

    (@eveums)

    Also wanted to note that I tried filling in the above like:
    elseif(is_single('badgers')) echo('header5');
    … and that didn’t work either.

    Wow, it’s like you two read my mind with this post exchange. I’ve been wondering about this for days.

    Does it work the same way for footer etc.?

    Do you have to call it with h1? Because it’s much better to have each post’s title be the h1, and not having dozens of pages with the exact same h1. I’m referring not only to users but search engines. Could you call it with a div? Is there a div in the header template?

    this plugin shd do the trick. is there another way to do it?
    https://txfx.net/code/wordpress/force-category-template/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Category Templates – Totally lost’ is closed to new replies.