Title: Change query var from s to q
Last modified: December 7, 2024

---

# Change query var from s to q

 *  Resolved [Griff](https://wordpress.org/support/users/blgerber/)
 * (@blgerber)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/change-query-string/)
 * Hi I have kind of an unusual task. I would like to change the query string shown
   in the url bar to use “?q=” instead of “?s=”
 * I’ve looked into altering the form as well as using some php to intercept and
   alter the query before sending it to Relevanssi.
 * I am using Elementor, but am okay creating a custom search submission form if
   need be.
 * I am not very experienced in the realm of search so any advice or resources would
   be very appreciated.
 * Thanks!
    -  This topic was modified 1 year, 5 months ago by [Griff](https://wordpress.org/support/users/blgerber/).

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

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/change-query-string/#post-18184096)
 * This isn’t about Relevanssi; using `s` as the query string parameter runs pretty
   deep in WordPress core. You can try modifying the query in the `parse_query` 
   hook: move the query string to `s` and set `is_search` to true there:
 *     ```wp-block-code
       add_action( 'parse_query', function( $query ) {  if ( isset( $_REQUEST['q'] ) && ! empty( $_REQUEST['q'] ) ) {    $query->set( 's', $_REQUEST['q'] );    $query->is_search = true;  }} );
       ```
   
 *  Thread Starter [Griff](https://wordpress.org/support/users/blgerber/)
 * (@blgerber)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/change-query-string/#post-18184717)
 * Hi Mikko,
 * Thanks for taking the time to respond even though I now see this might not be
   the most relevant place to post!
   I added your code, and interestingly now I can
   change the s to q in the url string and the query succeeds and returns results(
   it did not before), but when I just use the search bar, it still defaults to 
   using s.
 * Any other ideas? No worries if not, I have a lot better idea where to explore
   now!
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/change-query-string/#post-18184734)
 * You need to change the name of the `input` field in your search form from `s`
   to `q`.
 *  Thread Starter [Griff](https://wordpress.org/support/users/blgerber/)
 * (@blgerber)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/change-query-string/#post-18184855)
 * Oh wow, you’re my hero! Thanks so much for taking the time to help out! And best
   part is I’ve learned a little about how all this works. Very cool.
 * I’ve broken my counter function, but I’m pretty sure I can hopefully figure out
   a work around for this one.
 *     ```wp-block-code
       function total_search_results() {    if (is_search()) {        global $wp_query;        return $wp_query->found_posts;    }}function search_results_count_shortcode() {    return 'Total Results: ' . total_search_results();}add_shortcode( 'search_results_count', 'search_results_count_shortcode' );
       ```
   
 * Thanks again for taking the time, Relevanssi is super cool and I’m excited to
   use it!
    -  This reply was modified 1 year, 5 months ago by [Griff](https://wordpress.org/support/users/blgerber/).
 *  Thread Starter [Griff](https://wordpress.org/support/users/blgerber/)
 * (@blgerber)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/change-query-string/#post-18185112)
 * Actually in case anyone else finds this with similar goals, jet engine supports
   the count out of the box with dynamic tags! Thanks again for the help and making
   the community such a positive experience!

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

The topic ‘Change query var from s to q’ 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

 * [Query String](https://wordpress.org/support/topic-tag/query-string/)

 * 5 replies
 * 2 participants
 * Last reply from: [Griff](https://wordpress.org/support/users/blgerber/)
 * Last activity: [1 year, 5 months ago](https://wordpress.org/support/topic/change-query-string/#post-18185112)
 * Status: resolved