Title: new WP_Query
Last modified: July 23, 2019

---

# new WP_Query

 *  Resolved [tul60522](https://wordpress.org/support/users/tul60522/)
 * (@tul60522)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/new-wp_query/)
 * We have an existing plugin that is using this on a search page:
 *     ```
       global $query_string;
       $query_args = explode("&", $query_string);
       $search_query = array();
       if( strlen($query_string) > 0 ) {
           foreach($query_args as $key => $string) {
               $query_split = explode("=", $string);
               $search_query[$query_split[0]] = urldecode($query_split[1]);
           }
       }
   
       $search = new WP_Query($search_query);
   
       ...if($search->have_posts())...
       ```
   
 * The if $search->have_posts fires correctly when the Relevanssi plugin is OFF.
   When ON, search breaks. And if we replace the WP_Query with the following:
 *     ```
       $search = new WP_Query();
       $search->parse_query($search_query);
       relevanssi_do_query($search_query);
       ```
   
 * …the $search->have_posts() ends up empty. I’ve tried a few more options from 
   various support threads to no avail.
    -  This topic was modified 6 years, 10 months ago by [tul60522](https://wordpress.org/support/users/tul60522/).

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

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/new-wp_query/#post-11761547)
 * It should be
 *     ```
       $search = new WP_Query();
       $search->parse_query($search_query);
       relevanssi_do_query($search);
       ```
   
 * You have the wrong variable name there, that’s why it’s coming up empty.
 *  Thread Starter [tul60522](https://wordpress.org/support/users/tul60522/)
 * (@tul60522)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/new-wp_query/#post-11763186)
 * [@msaari](https://wordpress.org/support/users/msaari/) thank you. I could have
   sworn I tried this, but my eyes must have been just too tired yesterday. I really
   appreciate you getting back to me so quickly.

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

The topic ‘new WP_Query’ is closed to new replies.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=3529670)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [tul60522](https://wordpress.org/support/users/tul60522/)
 * Last activity: [6 years, 10 months ago](https://wordpress.org/support/topic/new-wp_query/#post-11763186)
 * Status: resolved