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:
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
(@blgerber)
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!
You need to change the name of the input field in your search form from s to q.
Thread Starter
Griff
(@blgerber)
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.
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, 3 months ago by
Griff.
Thread Starter
Griff
(@blgerber)
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!