Title: Running php code in WordPress pages
Last modified: August 20, 2016

---

# Running php code in WordPress pages

 *  [jinch](https://wordpress.org/support/users/jinch/)
 * (@jinch)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/running-php-code-in-wordpress-pages/)
 * Sorry if this is a daft question, but I could do with some guidance on the following
   if possible.
 * I had a website (not WordPress) that consisted of a number of php files, one 
   for each page plus a header.php, footer.php, navigation.php etc.
 * In each page file eg contact_us.php, I would add the following to the top of 
   the php file, after the DOCTYPE and before the HTML tag:
 * <?php $thisPage=”Contact us”; ?>
 * In navigation.php, I then had a series of IF statements like this:
 * <?php if ($thisPage==”Contact us”)
    echo ” class=\”sub_menu selected\””; else
   echo ” class=\”sub_menu\””; ?>>
 * This was to allow the navigation link for the page I was on to be highlighted.
 * I’ve now had my website moved into WordPress, and each original page has been
   added into WorPress as a ‘page’, according to the admin panel.
    But, each page
   no longer has the ‘<?php $thisPage=”Contact us”; ?>’ code in it, so the navigation
   highlight check can’t pick up which page I’m on. I tried installing Exec PHP 
   and adding ‘<?php $thisPage=”Contact us”; ?>’ to the top of each page, but it
   doesn’t seem to work.
 * Can anyone tell me what I need to do so that my navigation.php can pick up the
   $thisPage variable and handle it as it did pre-WordPress?
 * Many thanks for any help you can give.

The topic ‘Running php code in WordPress pages’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [jinch](https://wordpress.org/support/users/jinch/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/running-php-code-in-wordpress-pages/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
