Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm working on a project where each category should have a custom header page. Any suggestions? I'm just looking for some direction on how to accomplish this.

share|improve this question
    
0% accept rate on multiple questions. –  Brian Fegter Aug 30 '12 at 13:01
1  
Any progress? Was one of the answers helpful? Do you still miss something? –  toscho Oct 6 '12 at 22:30

3 Answers 3

Use the is_category() condtional statement

if(is_category('category-a-slug')){
    get_header('a');
}elseif(is_category('category-b-slug')){
    get_header('b');
}
share|improve this answer

Install the plugin Taxonomy Images. In your header.php check if you are in a category archive and if an image exists for that category. Then use that instead of the default image.

share|improve this answer
    
I hv 5 category and 5 header.php..each category should hv a different header...i.e. category A with header_a.php Category B with header_b.php any suggestion... –  Gopal Bhattacharjee Jun 13 '12 at 13:15

You can use custom templates for different categories. When displaying a category archive, WordPress will check for these files in order:

  1. category-{slug}.php
  2. category-{id}.php
  3. category.php
  4. archive.php
  5. index.php

Read more at the WordPress Codex


If you prefer to use the one category.php template, we can load custom header.php files based on the category's ID. Replace the call to get_header() in category.php with the following code:

global $wp_query;
get_header( 'category-' . get_query_var('cat') );

WordPress will then look for header-category-{category_id}.php and load that file if found. Otherwise, header.php will be loaded as normal.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.