[resolved] unique header image for each category, all clickable? help? (6 posts)

  1. crazypaws
    Posted 8 years ago #

    I have two huge wishlist items for my header that I've been struggling to implement. Hoping someone can help me out?

    1) I want to have a unique header image for all parent categories (child categories would have the same image as the parent - doesn't matter whether this is elegantly incorporated or i have to specify the image for each category including the children)

    2) I'd like all of the header images to be clickable and link back to home on click.

    Both of these goals seem to be frequently wished for. I've been reading through the forums and codex and getting overwhelmed with all the different discussions; especially in trying to make the mods on the theme I've chosen.

    I'm trying to make the mods on the theme Water3 by theundersigned. The theme is great, with cool drop down menus and a minimalist style, but it uses a complicated header.php file and style.php to work its magic. There have been more than 25k downloads of this theme between the 2 and 3 column versions - so I'm hoping given the popularity someone out there can and will help? or has made these changes already?

    I've tried many of the methods I've seen explained, tried to work backwards from theme templates that incorporate this, tried to reverse engineer from sites doing it - I've spent hours and hours - but I'm missing something and can't seem to get it right with this theme. I'm a wordpress beginner (which is probably the root of my problems) . I'm sure I'm missing something easy but after a week of trying to do just these two things, I clearly need help. Can anybody help this wordpress newbie out?

    I found one example of category changing header images on the water theme here

    I'm running the theme on a development box until I get all this sorted out so can't point any would-be helpers to my site but I can post code if needed. I'm using wordpress 2.1.

    some of the topics I've been through looking for help with this:

    thanks any and all kind enough to help.

  2. crazypaws
    Posted 8 years ago #

    just to clarify/follow up on my earlier request for help -
    I do know that changing <div id="headerimage"> in my header.php file to `<div id="headerimage" onclick="location.href='<?php bloginfo('url'); ?
    >';" style="cursor: pointer;">` will make my header image clickable. I just want to be sure that any code to change images based on categories doesn't break that - hence the joined wish list of two things.

    also - the example I linked for a site with header images that change based on category turns out to use a plugin to randomly choose a header pic. It is not coded with a specific pic per category.

    any help anyone can provide would be much appreciated. thanks.

  3. Chris_K
    Posted 8 years ago #

    Might be reaching here, but maybe this plugin would help? http://guff.szub.net/2005/07/21/post-templates-by-category/

  4. crazypaws
    Posted 8 years ago #

    thanks Handy. I looked at that plugin and it may help as a last resort but I'd prefer to try and code it in directly.

    The theory I've found in the codex and support forum that seems most fitting, is to add some lines to header.php like:

    class="<?php if (is_home()) echo('headerimage1');
    elseif(is_category('red') ) echo('headerimage2');
    elseif(is_category('sox') )echo('headerimage3'); ?>

    I'd then add entries to style.php for each of the headerimage examples - header2, header3, etc. that specify different pictures by url.

    Red and Sox would be actual category names in the code (might also work with category ID numbers but don't know).

    In theory, the is_category string could also be set up nested such that 1 image could be applied to a parent category and all its children, or some variation. something like 'is_category('red', 'blue')'. That way one line would allow a single category and all its children to call for 1 headerimage.

    adding to the approach for pages (which is not needed for me but might be for some), you could (again in theory) use elseif(is_page) in place of elseif(is_category) and the call would then allow specific header images for pages too.

    The theory sounds easier and cleaner than the approach of creating tons of custom category.php templates or using a plugin - both of which others have suggested....still so far, with the water theme, i haven't gotten it to work.

    It may just be that I've been working on things too much and I'm missing something easy or making a rookie mistake like putting the code lines in the wrong place. Not sure. For that matter, maybe I've got something wrong in the above theory?

    any further help always appreciated. cheers.

  5. smackcell
    Posted 8 years ago #

    I'd like to make my header image clickable and I noticed this in crazypaw's post:

    I do know that changing <div id="headerimage"> in my header.php file to `<div id="headerimage" onclick="location.href='<?php bloginfo('url'); ?
    >';" style="cursor: pointer;">` will make my header image clickable.

    Is it <div id="headerimage"> or <div id="headerimg">? The latter is what I see in my header.php file. Am I looking in the right place? I am using WP 2.1.

  6. crazypaws
    Posted 8 years ago #

    the name of the Div ID used could be anything. It is specific to your theme and how it was defined in your CSS (see your style.css file or style.php if your theme works that way).

    If your theme uses headerimg as the term, than you would use that instead. in my theme I have the image component defined as headerimage. that's all.

    Do note that there are many ways to make your header into a clickable link. The javascript method I used was because of some other stuff i was trying to sort out.

    if you know basic html, you can wrap the call for your header image in an anchor <a href=' link ' /a> kind of thing and it would work without the javascript approach.

Topic Closed

This topic has been closed to new replies.

About this Topic