Title: Query database without get_header() ?
Last modified: August 19, 2016

---

# Query database without get_header() ?

 *  Resolved [freshifreshy](https://wordpress.org/support/users/freshifreshy/)
 * (@freshifreshy)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/query-database-without-get_header/)
 * I want to create a php file that queries the database for posts, then I want 
   to call on that php file with ajax to load in that content.
 * I was hoping to do this without having to create a page and assign it a template,
   but it seems that if I don’t do this, I can’t use WordPress’ query tags, etc.
 * I’d like the PHP file to be as unobtrusive as possible.
 * What would be the best, most secure way to do this?

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

 *  Thread Starter [freshifreshy](https://wordpress.org/support/users/freshifreshy/)
 * (@freshifreshy)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/query-database-without-get_header/#post-1480070)
 * I guess what I’m asking is: Is there a way to take advantage of the WordPress
   codex for querying posts, etc., but without having to assign a template to the
   page?
 *  Thread Starter [freshifreshy](https://wordpress.org/support/users/freshifreshy/)
 * (@freshifreshy)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/query-database-without-get_header/#post-1480146)
 * I think I’ve discovered that the answer is no. So instead I’ve used
 *     ```
       if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) { 
   
       // do something 
   
       }
       ```
   
 * Using this, I created the page I need when the template loads.
 * Was hoping to get around this, but ah well.

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

The topic ‘Query database without get_header() ?’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [freshifreshy](https://wordpress.org/support/users/freshifreshy/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/query-database-without-get_header/#post-1480146)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
