Title: adding an SQL post query into wp_query
Last modified: August 20, 2016

---

# adding an SQL post query into wp_query

 *  [roryrothon](https://wordpress.org/support/users/roryrothon/)
 * (@roryrothon)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/adding-an-sql-post-query-into-wp_query/)
 * I am developing a miltisite network Marketplace.
 * I can pull posts from all of my children blogs via an sql query, but is there
   a way that i can add this into an already declared WP_Query(); ?
 * I have posted some pastebins to make life that little easier lol.
 * 1) This is a function that queries posts ready for a “Portfolio” page template:
   
   [http://pastebin.com/vX8B7QQr](http://pastebin.com/vX8B7QQr)
 * Notice the $portfolio_query = new WP_Query($portfolio);
    The page template loop
   starts (minus all the other stuff): $portfolio_query->have_posts
 * 2) I am using an sql query by pulling all PUBLISHED posts into an array. Im not
   an expert coder and i am still learning, & loving it so.
 * Could someone be kind enough to show there own FULL example of a multisite sql
   post query? i assume i need to use setup_postdata() somewhere in there too?
 * The general idea is to create the “Multisite” query, and somehow merge this query
   with the above declared $portfolio_query.
 * Any help or advice would be great.
    Thank
 * Rory

Viewing 1 replies (of 1 total)

 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [13 years, 11 months ago](https://wordpress.org/support/topic/adding-an-sql-post-query-into-wp_query/#post-2830071)
 * Multisite is the same as Singlesite, there’s just not one query to run to search
   all the posts. Each site has its posts in it’s own table.

Viewing 1 replies (of 1 total)

The topic ‘adding an SQL post query into wp_query’ is closed to new replies.

## Tags

 * [Merge](https://wordpress.org/support/topic-tag/merge/)
 * [multisite](https://wordpress.org/support/topic-tag/multisite/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Networking WordPress](https://wordpress.org/support/forum/multisite/)
 * 1 reply
 * 2 participants
 * Last reply from: [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/adding-an-sql-post-query-into-wp_query/#post-2830071)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
