Title: Detecting Page Template in Header.php
Last modified: August 19, 2016

---

# Detecting Page Template in Header.php

 *  Resolved [foochuck](https://wordpress.org/support/users/foochuck/)
 * (@foochuck)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/detecting-page-template-in-headerphp/)
 * I’d like to put a code in my header.php file that will detect what page template
   is being used.
 * For example I have two page templates:
 * page-template-1.php
    page-template-2.php
 * If page-template-1.php I would like to display menu 1 in header.php and if page-
   template-2.php is being used I would like to display menu 2 in header.php
 * Can anyone set me in the right direction for the code to use in header.php to
   detect the page template?
 * Thanks!
 * -foo

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

 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/detecting-page-template-in-headerphp/#post-1809044)
 *     ```
       <?php
   
       if ( is_page_template('page-template-1.php') ) {
   
       stuff
   
       } elseif ( is_page_template('page-template-2.php') ) {
   
       different stuff
   
       }
   
       ?>
       ```
   
 *  Thread Starter [foochuck](https://wordpress.org/support/users/foochuck/)
 * (@foochuck)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/detecting-page-template-in-headerphp/#post-1809048)
 * Awesome. Thank you [@rev](https://wordpress.org/support/users/rev/). Voodoo!
 *  Thread Starter [foochuck](https://wordpress.org/support/users/foochuck/)
 * (@foochuck)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/detecting-page-template-in-headerphp/#post-1809057)
 * One other question on this topic – how can I do the same thing to test what page
   is currently being used? Would I need to test the page ID or page title?

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

The topic ‘Detecting Page Template in Header.php’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [foochuck](https://wordpress.org/support/users/foochuck/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/detecting-page-template-in-headerphp/#post-1809057)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
