Title: modify PHP array for switching out header images
Last modified: August 19, 2016

---

# modify PHP array for switching out header images

 *  [mmartucci](https://wordpress.org/support/users/mmartucci/)
 * (@mmartucci)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/modify-php-array-for-switching-out-header-images/)
 * Hi guys I currently have this array, which I had help writing, which switches
   out the header images for several different categories.
 * Now, I need a custom header image for a page instead of a category. It’s just
   one right now, but it will probably be more later, so I’m thinking I should keep
   the array format?
 * Anyway, here’s the code I currently have and I’d be making
 * ‘shop-2’ => ‘headercat14’
 * This code is contained within the header.php file:
 *     ```
       <?php
       $c = get_query_var('cat');
       $cat = get_category ($c);
   
       $headers = array(
           'americans-want-peace' => 'headercat01',
           'all-nations-want-peace' => 'headercat02',
           'all-religions-want-peace' => 'headercat03',
           'all-people-want-peace' => 'headercat04',
           'military-america' => 'headercat05',
           'worldwide-warfare' => 'headercat06',
           'persecuting-peacemakers' => 'headercat07',
           'glorifying-war-with-mass-media' => 'headercat08',
           'non-violence-works' => 'headercat09',
           'war-wrecks-usa-economy' => 'headercat10',
       	'united-peace-and-green-movements' => 'headercat11',
       	'save-the-children-social-justice' => 'headercat12',
       	'peace' => 'headercat13',
       	'shop-2' => 'headercat14'
       );
   
       $divid = isset($headers[$cat->slug]) ? $headers[$cat->slug] : 'header';
   
       ?>
       ```
   

The topic ‘modify PHP array for switching out header images’ is closed to new replies.

## Tags

 * [header image](https://wordpress.org/support/topic-tag/header-image/)
 * [header images](https://wordpress.org/support/topic-tag/header-images/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 0 replies
 * 1 participant
 * Last reply from: [mmartucci](https://wordpress.org/support/users/mmartucci/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/modify-php-array-for-switching-out-header-images/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
