Title: custom PHP in page.php
Last modified: August 19, 2016

---

# custom PHP in page.php

 *  Resolved [erniebornheimer](https://wordpress.org/support/users/erniebornheimer/)
 * (@erniebornheimer)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/custom-php-in-pagephp/)
 * Hi
 * I have a set of related pages. They each need to pull data from the database,
   but slightly different SQL query, depending on the page. I’ve created a template
   for these pages, and it works fine.
 * Is the page slug or title in a variable that I can use in the page template? 
   I’m picturing something like:
 * – if $page = $such-and-such, run SQL_query_x
    – elseif $page = $so-and-so, run
   SQL_query_y
 * I should mention I’ve looked at plugins to get this functionality, but for one
   reason and another, plugins are not the way to go for me at this time, and I 
   want to try something else. Can it be done? How can I get to which page is being
   loaded?
 * Thank you!
 * Ernie Bornheimer

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

 *  [Samuel B](https://wordpress.org/support/users/samboll/)
 * (@samboll)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/custom-php-in-pagephp/#post-969192)
 * [http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page](http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page)
 *  Thread Starter [erniebornheimer](https://wordpress.org/support/users/erniebornheimer/)
 * (@erniebornheimer)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/custom-php-in-pagephp/#post-969275)
 * samboll
 * Thank you! That’s exactly what I was looking for…
 * (note to self: next time, RTFM before posting)
 * Ernie

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

The topic ‘custom PHP in page.php’ is closed to new replies.

 * 2 replies
 * 2 participants
 * Last reply from: [erniebornheimer](https://wordpress.org/support/users/erniebornheimer/)
 * Last activity: [17 years, 4 months ago](https://wordpress.org/support/topic/custom-php-in-pagephp/#post-969275)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
