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.

  • 1
    Any progress? Was one of the answers helpful? Do you still miss something? – fuxia Oct 6 '12 at 22:30

Use the is_category() condtional statement

| 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.

| 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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