Title: Variable in header.php not found in index.php
Last modified: August 18, 2016

---

# Variable in header.php not found in index.php

 *  [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/variable-in-headerphp-not-found-in-indexphp/)
 * Aloha,
 * I want to add a variable to my template header.php, so I can easily enable/disable
   ads, etc.
 * <?php $adsSwitch = false; ?>
 * Problem is I can’t see it in index.php. There is no problem accessing it in header.
   php.
 * <?php
 * if($adsSwitch == true)
    { // Show annoying ads }
 * ?>
 * Thanks.

Viewing 1 replies (of 1 total)

 *  [mrvox](https://wordpress.org/support/users/mrvox/)
 * (@mrvox)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/variable-in-headerphp-not-found-in-indexphp/#post-612521)
 * yep, same here. added some code to the header.php and try to read the variables
   in sidebar.php – they are gone it seems.

Viewing 1 replies (of 1 total)

The topic ‘Variable in header.php not found in index.php’ is closed to new replies.

 * 1 reply
 * 2 participants
 * Last reply from: [mrvox](https://wordpress.org/support/users/mrvox/)
 * Last activity: [18 years, 7 months ago](https://wordpress.org/support/topic/variable-in-headerphp-not-found-in-indexphp/#post-612521)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
