WordPress.org

Ready to get started?Download WordPress

Forums

How to Add a Unique Header Image to each Category (8 posts)

  1. TeresaCrumpton
    Member
    Posted 1 year ago #

    I've installed 2011 and a custom header for the home page. I really want a different header for each of 7 other categories. Can that be done?
    I made a page that looks like I want the category to look, but I want it to work like a blog.

    Thanks in advance for sharing your expertise.
    Teresa

  2. Rebecca Schaefer
    Member
    Posted 1 year ago #

    Yes, you can do this. You'd want to use conditional tags (such as is_category) to determine which category you're in, and, if so, show the image associated with that category. Example

    <?php
    // if we're in a category
    if(is_category()):
       // get the name of the category
       $category = single_cat_title('', false);
       ?>
       // get the image with the same name as the category and display
       <img src="<?php bloginfo('template_directory ');"/images/<?php echo($category); ?>.jpg" />
       <?php
    endif;
    ?>

    See also: is_category, single_cat_title, bloginfo

  3. esmi
    Forum Moderator
    Posted 1 year ago #

    It could be done via a child theme and some custom functions + a custom header.php template file.

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    I made a page that looks like I want the category to look, but I want it to work like a blog.

    possibly create a page template for it; http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates
    with a custom query for the category posts; http://codex.wordpress.org/Class_Reference/WP_Query

    it might help if you post a link to your site to illustrate the look of the page.

    you can use a 'featured image' with a minimum width of 1000px to act as a custom header for any static page.

  5. TeresaCrumpton
    Member
    Posted 1 year ago #

  6. TeresaCrumpton
    Member
    Posted 1 year ago #

    Thank you, I will try the template. I can't have a blog on a static page, can I?

  7. Rebecca Schaefer
    Member
    Posted 1 year ago #

    alchymyth has a really good idea and a better implementation. If you create a custom page template, you can tell it to display posts. It's more involved from a coding perspective, but overall much cleaner.

  8. esmi
    Forum Moderator
    Posted 1 year ago #

    Yes you can. See a page of posts for examples.

Topic Closed

This topic has been closed to new replies.

About this Topic