Title: Custom SQL queries
Last modified: August 19, 2016

---

# Custom SQL queries

 *  [barelytone](https://wordpress.org/support/users/barelytone/)
 * (@barelytone)
 * [17 years ago](https://wordpress.org/support/topic/custom-sql-queries/)
 * Hi, to all out there. I’m wondering if it is possible to do straight custom SQL
   queries into the wordpress database while still making use of the templates. 
   Obviously, one could use wp-admin as a backend content management system, and
   then do a separate webpage outside of the wordpress directory.
 * Still I like the usability of the themes, but find the template tags a bit limited
   for what I’m trying to accomplish (in general), even though very convenient. 
   As such it would be nice to be able to combine standard SQL queries with template
   tags.
 * However, I’ve found that when I submit an SQL query, it messes up $wp_query, 
   and my content within the loop is altered. I don’t understand fully why, but 
   I’d like to be able to SQL queries without making a new $WP_query object, and
   without messing up the $wp_query object that is standard for the wordpress loop.
   Is this possible to acheive?

The topic ‘Custom SQL queries’ is closed to new replies.

## Tags

 * [SQL queries](https://wordpress.org/support/topic-tag/sql-queries/)
 * [the-loop](https://wordpress.org/support/topic-tag/the-loop/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 0 replies
 * 1 participant
 * Last reply from: [barelytone](https://wordpress.org/support/users/barelytone/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/custom-sql-queries/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
