WAIT: Search Filter Doesn't read URL Parameter

I’m using the search filter with the following details:

Screenshot 2025-02-13 at 15-48-57 Product Shop Grid v2 (Template)

On my site I have a simple search form:

<form method="get" class="form-search" action="/page1/">
<input type="search" class="search-field"  placeholder="Search Products" name="_product_search">    
<button class="search-submit" type="submit">Submit</button>
</form>

It almost works, when I submit the search, it directs to the correct page the URL is

.com/page/?_product_search=test

But it doesn’ show any results, if I manually press ENTER on the url of the browser then _product_search does take NOT effect either!

Is this a bug or am I missing something here?

EDIT: Here is a screenshot, I have the proper url but the result show:

If I enter “test” via the filter the proper result shows.

EDIT UPDATE: I disabled Relevanssi Search and it’s now ok, but I need to have Relevanssi ACTIVE. Please advise.

Thanks.

1 Like

I did testing. If I keep my bricks URL search parameter as “s” it works. but the bricks options says “Define a unique, more readable URL parameter name for this filter.” I’m not sure is there a way to define a unique bricks parameter here and then do I try to update the “s” in WP? Or is there some other filter that can be used?

Hi @dailce ,

Based on your screenshot, the parameter is taking effect and so the search input and active filter showing “test”

If the query is not having a result, please check if you have any third-party filter plugin installed that could conflict with Bricks.

Otherwise, please send admin credentials to help@bricksbuilder.io (Include this thread URL as reference) so we can check.

Regards,
Jenn

Relevanssi Search seems to be hijacking the search query, the workaround is to use “s” as the search parameter, which isn’t ideal I don’t think…

I FOUND A FIX: this will allow you to continue to use the Brickbuilder filter, and prevent Relevanssi from taking over:

add_filter( 'bricks/posts/query_vars', function( $query_vars, $settings, $element_id ) {
	if ( $element_id === '56f380' ) {  //the brick query loop element
		
		remove_filter( 'posts_request', 'relevanssi_prevent_default_request' ); //interferese with bricks search filter parameter
		//remove_filter( 'posts_pre_query', 'relevanssi_query', 99 );
		
		add_filter( 'relevanssi_orderby', function( $orderby ) { return 'menu_order'; } ); //should match bricks query menu order 
		add_filter( 'relevanssi_order', function( $order ) { return 'asc'; } );
		$query_vars['relevanssi'] = true; //APPLY relevanssi to the bricks ajax search  see: https://www.relevanssi.com/user-manual/using-relevanssi-outside-search-pages/
  
		//print( '<pre>' . print_r( $query_vars, true ) . '</pre>' );
	}

	return $query_vars;
}, 10, 3 );

Hi,

I’m trying to use your code snippet to get Relevanssi working with Bricks Builder’s query loop search, but I’m hitting a confusing problem.

About the element ID - In your example, you use $element_id = '56f380'.

I’m not exactly sure where this ID comes from or how to find the right one for my Query Loop.

Could you explain exactly where to get this value? I tried using the ID of the looped element (a card).

I also tried without your code snippet. You explained that it was possible if we set the Bricks search filter’s URL parameter to ‘s’. That doesn’t work for me. But if I set the URL parameter to something else than ‘s’ - for example ‘text_search’ - and then do a search, the results don’t show up.

BUT if I then manually change the URL from ?text-search=my-search-query to ?s=my-search-query, I get the correct results. So I know Relevanssi is working and is indexing my ACF fields and taxonomies.

So it only works when Bricks is NOT using ‘s’ as the query parameter, and I have to manually change the URL for results to show up.

I really don’t know what to try next. I’m so confused.

I would really appreciate any help you can give me on how to get this working.

Thank you.

Yeah I was getting mixed results and haven’t revisited this. But element id is the bricks id of the element that your query is on.

Thanks for your reply… I was not able to get it to work. But I got a different solution from Jenn that searches on a posts meta-data - including all the ACF fields. So no need to use Relevanssi.

Jenn also told me that the Bricks team is currently working on an implementation of “search criteria” that will cover a lot of the same areas as Relevanssi: Roadmap – Bricks