Title: calling a specific header
Last modified: August 18, 2016

---

# calling a specific header

 *  [Legion](https://wordpress.org/support/users/legion/)
 * (@legion)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/calling-a-specific-header/)
 * I’m trying to get my header (that’s visual header not <header>) to change depending
   on what category the post is in.
 * To start with I have this as my code:
 * //<?php
    // code for changing headers if (is_home()) { // homepage echo “<style
   type=’text/css’> #masthead { background: url([http://www.bombshellstudios.com/legion/images/banner.jpg](http://www.bombshellstudios.com/legion/images/banner.jpg));}
   </style>”; } elseif (is_category(3)) { // ironquest category echo “<style type
   =’text/css’> #masthead { background: url([http://www.bombshellstudios.com/legion/images/iron_header.jpg](http://www.bombshellstudios.com/legion/images/iron_header.jpg));}
   </style>”; } elseif (is_category(9)) { // ironquest category echo “<style type
   =’text/css’> #masthead { background: url([http://www.bombshellstudios.com/legion/images/iron_header.jpg](http://www.bombshellstudios.com/legion/images/iron_header.jpg));}
   </style>”; } elseif (is_category(2)) { // book of emptiness category echo “<style
   type=’text/css’> #masthead { background: url([http://www.bombshellstudios.com/legion/images/boe_header.jpg](http://www.bombshellstudios.com/legion/images/boe_header.jpg));}
   </style>”; } else { // everything else echo “<style type=’text/css’> #masthead{
   background: url([http://www.bombshellstudios.com/legion/images/banner.jpg](http://www.bombshellstudios.com/legion/images/banner.jpg));}
   </style>”; } //?>
 * This works great when clicking a category but if I click the title of a post,
   or any other way of accessing a single post, it doesn’t work. By the way this
   script is in my <header></header>. My question is, how do I call the category
   of any post that is made so that this script will recognize it, even if the category
   itself wasn’t how it was accessed?
 * I hope I made this clear. Thanks for any help.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/calling-a-specific-header/#post-187943)
 * This might help:
 * [http://codex.wordpress.org/Template_Tags/in_category#Use_OUTSIDE_The_Loop](http://codex.wordpress.org/Template_Tags/in_category#Use_OUTSIDE_The_Loop)
 * A template option:
 * [http://wordpress.org/support/topic.php?id=27821#post-156289](http://wordpress.org/support/topic.php?id=27821#post-156289)
 * ([more info on category templates](http://codex.wordpress.org/Category_Templates))
 *  Thread Starter [Legion](https://wordpress.org/support/users/legion/)
 * (@legion)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/calling-a-specific-header/#post-187956)
 * Thanks! Gonna play around with that a bit and see what I can make happen.
 *  Thread Starter [Legion](https://wordpress.org/support/users/legion/)
 * (@legion)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/calling-a-specific-header/#post-188205)
 * That generally pointed me in the right track! Thanks, I got it working.
 * I ended up taking the code out of the header and creating seperate headers that
   are called from the singles.php page like such:
 *  <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
 *  <?php if ( in_category(‘2’) ) {
    include “boe_header.php”; } elseif ( in_category(‘
   3’)) { // ironquest category include “iron_header.php”; } elseif ( in_category(‘
   9’)) { // ironquest category include “iron_header.php”; } else { include “header.
   php”; } ?>
 * Again, thanks for the help.
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/calling-a-specific-header/#post-188206)
 * I’m glad you found a way to do it.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘calling a specific header’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * Last activity: [21 years, 1 month ago](https://wordpress.org/support/topic/calling-a-specific-header/#post-188206)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
