Site logo

[Resolved] Filter query loop with search and filter pro

Home Forums Support [Resolved] Filter query loop with search and filter pro

Home Forums Support Filter query loop with search and filter pro

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2340521
    Walter

    First of all, I looove GenerateBlocks. Thank you for all your hard work on this.

    Here is my issue:

    I am using the GB query loop to add posts to a page. I would like to filter those posts with Search and Filter pro. According to S&F, if the query is using wp_query I can pass in the id of the search form: https://searchandfilter.com/documentation/search-results/custom/

    I tried to use this code based on your support articles to pass it in but it is not working:

    add_filter( 'generateblocks_query_loop_args', function( $query, $attributes ) {
        if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'sf-search' ) !== false ) {
            $args = array('post_type' => 'post');
            $args['search_filter_id'] = 711;
            $query = new WP_Query($args);
        }
        return $query;
    }, 10, 2 );

    Am I missing something? The search filters don’t update the query posts. You can sign in and check it out on the /hotspots page.

    Thank you for your help!

    #2341446
    David
    Staff
    Customer Support

    Hi there,

    i am not familiar with the Search Filter Pro, and i assume that search_filter_id is a custom parameter?

    What happens if you just pass that parameter to the query like so:

    
    add_filter( 'generateblocks_query_loop_args', function( $query, $attributes ) {
        if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'sf-search' ) !== false ) {
            $args['search_filter_id'] = 711;
        }
        return $query;
    }, 10, 2 );
    #2341891
    Walter

    Thanks Dave!I found a different approach that works; I tried this but still no success. However, I think it’s because I’m not doing something right on the Search and Filter end. Either way, I found a solution (S&F has an option to force the search to use is_search; with that I was able to use the regular archives and filter them accordingly, if that makes sense).

    I have to say: you are by far the one of the greatest assets to GP. GP is what it is because of you and many of your other colleagues. Keep up the awesome work!

    #2341903
    David
    Staff
    Customer Support

    Wow – thank you for your kind words – we really appreciate hearing that!!

    I am glad to hear you found a solution to the problem 🙂

    #2601202
    Lorenzo

    Hi everyone,
    I’m sorry to reopen this thread.

    I searched in other threads for a possible solution but found none.

    I basically have the same issue as Walter had: I have created a query loop to show posts on a page and wanted to sort/filter them in frontend via search &filter pro plugin, but I don’t seem to find a way to do so.

    I love creating query loops with the GB dedicated block, it’s intuitive and it allows you do design the loop item easily.
    But it seems that it’s not possible to sort/filter them in frontend.

    I know that Search&filter pro plugin works fine with the basic wordpress loop, and that I can also style the loop item with the content block element, but I wanted to add a query loop in a particular page and needed to filter them.

    Do you happen to know how I could do that? Or are you planning to implement a way to do so in a future release (it would be a really great feature)?

    Thanks!

    #2601538
    Ying
    Staff
    Customer Support

    Hi Lorenzo,

    I don’t think there is a way currently, unfortunately.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.