WordPress.org

Ready to get started?Download WordPress

Ideas

Changing Header Image According To Category

  1. saitam
    Member

    12345

    Maybe someone finds the time to write a plugin that allowed me to allocate different header images to my categories.

    I run a blog that rates different service providers with many categories (and subcategories) from car rentals to veterinaries, and it would be great if my readers could instantly see what category they are browsing by getting a distinctively different look and feel of the theme for posts in each category via the prominent header image.

    Posted: 6 years ago #
  2. craigchilds
    Member

    there are two ways to do this easily.
    the first is to get a plugin called Post Templates By Category:
    http://guff.szub.net/2005/07/21/post-templates-by-category/
    and then you can make category-1.php templates for each category.

    the easier method is to call a new header based on which category we're in, kind of like this:

    <img src="/<?php $category = get_the_category(); echo $category[0]->cat_name; ?>.jpg">

    which will turn into:

    <img src="/category.jpg">

    Posted: 6 years ago #
  3. hanasakicho
    Member

    HI Craigchilds,

    After playing around with your second suggestion, i finally got it to work... almost :)

    I got it working for sub-categories but it doesn't work for the main category.

    For example, with my template, the category pages are created by archives.php.

    I have a main category called "Autos" and a sub-category called "Honda."

    The image for sub-category Honda will show both on the main category page and the sub-category page, where as the Autos image doesn't show at all.

    Since im kind of a newbie, it would take me a lifetime to figure it out, so i thought i would pick your brain.

    Any suggestions?

    Posted: 5 years ago #
  4. thepyt
    Member

    Where does the above mentioned code go? In the default stylesheet?

    Posted: 5 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.

  • Rating

    12345
    4 Votes
  • Status

    This is theme territory