Site logo

Archived topic

Search & Filter Pro plugin

3 replies · Started by Sigfus on December 26, 2022

Viewing posts 1–4 of 4

Hi there

I´m building my first WP webste with the GeneratePress theme and GenerateBlocks. The best WP theme/blocks I have used so far!

I have been trying to get the Search & Filter Pro plugin to work on this website to filter custom post type archives but so far without success. I then came across the following post from April this year in this forum:

https://generatepress.com/forums/topic/search-and-filter-plugin/

If I understand this correctly Search&Filter does not work with the GeneratePress theme but you are working on it. What is the status of that update now?

Best regards
Sigfús

Hi Sigfus,

We recommend now using GenerateBlocks' Query Loop Block for queries.

With this, you can filter in the Search & Filter ID for it to work.

Specifically, you could try adding this snippet:

add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
		if ( ! is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'cu-query' ) !== false ) {
			$query_args['search_filter_id'] = 123;
		}
 
		return $query_args;
	}, 10, 2 );

Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

Then, give the Grid Block of the Query Loop a class of cu-query.

Adding Custom Classes: https://wordpress.com/support/wordpress-editor/adding-additional-css-classes-to-blocks/

This code adds the Search & Filter ID as an argument to the Query.

Dear Fernando
I got it to work! Thanks a millon!
Sigfús

You're welcome, Sigfus!

This archived topic is closed to new replies.