Title: Pass query parameters
Last modified: September 1, 2016

---

# Pass query parameters

 *  Resolved [cooper_hu](https://wordpress.org/support/users/cooper_hu/)
 * (@cooper_hu)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/pass-query-parameters/)
 * Hey!
 * I have a custom post type I am using relevanssi to search through, except I want
   to pass a meta_query parameter to the search to exclude certain posts that have
   an Advance Custom Field True/False field checked.
 * I’m trying (which may be wrongly) to use WP_Query as pass the search term in 
   as a parameter but it is not displaying the results I am looking for.
 *     ```
       <?php $args = array(
           'post_type' => $_GET['search-type'],
           'posts_per_page' => 3,
           's' => $_GET['s'],
           'meta_query' => array(
               array(
                   'key' => 'work_hidden',
                   'value' => '0',
                   'compare' => '='
               )
           )
       ); 
   
       $the_query = new WP_Query( $args ); 
   
       if ( $the_query->have_posts() ) {
           while ( $the_query->have_posts() ) {
               $the_query->the_post();
       	include "partials/work-card-new.php";
           }
       } ?>
       ```
   
 * In theory this query should work fine, but from the research I’ve done I may 
   need to use a Relevanssi function to pass my meta_query into the search. Any 
   help is appreciated thank you!
 * [https://wordpress.org/plugins/relevanssi/](https://wordpress.org/plugins/relevanssi/)

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

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/pass-query-parameters/#post-7556343)
 * When you use `new WP_Query()`, you’re essentially dropping Relevanssi off the
   search. Instead use `relevanssi_modify_wp_query` or `pre_get_posts` filter hooks
   to add the `meta_query` to the query parameter before it is passed to Relevanssi.
 * If you really do need to run a new query on the template (which usually is not
   the best way to do it, as it then you’ll end up running two queries, which wastes
   resources), add
 * `relevanssi_do_query( $the_query );`
 * after the `new WP_Query()` line in order to get Relevanssi to process the query.
 *  Thread Starter [cooper_hu](https://wordpress.org/support/users/cooper_hu/)
 * (@cooper_hu)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/pass-query-parameters/#post-7556434)
 * Thanks for getting back to me Mikko! I was able to solve my problem using the
   pre_get_post filter hook! Whoop Whop!

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

The topic ‘Pass query parameters’ 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/)

## Tags

 * [ACF](https://wordpress.org/support/topic-tag/acf/)

 * 2 replies
 * 2 participants
 * Last reply from: [cooper_hu](https://wordpress.org/support/users/cooper_hu/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/pass-query-parameters/#post-7556434)
 * Status: resolved