FacetWP with Container Query Loop Builder

Has anyone managed to get FacetWP working with the Container Query Loop Builder?

1 Like

where you able to solve this?

No, I ended up just using a shortcode and coding it manually

1 Like

i found a video I am sure you already did about using custom queries in wpfacets to link the filter action.

tks

It’s official supported now. Bricks | FacetWP

Hi! I am still having problems - I have the Bricks addon and followed the instructions for adding facets and selecting the use facetwp on the query. The facets show up when the page loads, but they do not filter the loop of posts showing. It would be helpful if someone could help with the details. I am doing this for the archive pages. This seems to only be an issue on archive templates. I created a page I and added the same code on that page and the facets do work with the loop query. I suspect it is something to do with the archive bit.

In order for it to work at archive page, the following must be written in functions.php:

add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
    if ( $query->is_archive() && $query->is_main_query() ) {
        $is_main_query = false;
    }
    return $is_main_query;
}, 10, 2 );

See also documentation: Using a WP Archive Page | FacetWP

I hope it helps someone

1 Like

Did anyone get this to work? Tried doing the functions.php filter thing, still no luck. Filters work outside the archive template.

Did you test this? Could not get it to work.

Can you explain in a little more detail what the problem is?

Unfortunately I can’t run facetwp on the archive page (shop page) either.
I added the code Astwert mentioned, but no success :frowning:
Facetwp works if the page is not archive type.
Any ideas?

Single page with facetwp - works fine:
https://budujdom.pl/projekty-domow/?_kategorie=domy-do-70-m2

Archive page, with the same template used - don’t work:

2 Likes

Same here, pretty weird that it works when it is not set up as an archive :-/

@pedronx @Michal

I personally switched to Filter Everything, but the code below (from FacetWP) worked for me when I used it with Bricks. Added to Bricks child theme funcions.php

// Let FacetWP ignore the native archive query add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) { if ( $query->is_archive() && $query->is_main_query() ) { $is_main_query = false; } return $is_main_query;

}, 10, 2 );

// Temporary patch for Facetwp + bricks integration
add_action(‘init’, function() {
remove_action( ‘bricks/archive_product/before’, [Bricks\Theme::instance()->woocommerce, ‘setup_query’],10,2 );
});

1 Like

Hi @hihaavard :slight_smile: thank you so much for the code. It is throwing some error. Do you think you could help me with this? Thank you in advance​:pray:

Adding all three of these worked for me with the products widget on the archives page.

/**
 * Activate FacetWP on brick products block
 */
add_filter( 'bricks/posts/query_vars', function( $query_vars, $settings, $element_id ) {
  if ( $element_id === '641c6c' ) { // change value to your Products element's unique element ID
    $query_vars['facetwp'] = true;
  }

  return $query_vars;
}, 10, 3 );

add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
  if ( $query->is_archive() && $query->is_main_query() ) {
    $is_main_query = false;
  }
  return $is_main_query;
}, 10, 2 );

// Temporary patch for Facetwp + bricks integration
add_action('init', function() {
  remove_action( 'bricks/archive_product/before', [Bricks\Theme::instance()->woocommerce, 'setup_query'], 10,2 );
});
1 Like

Is there anyone who uses FacetWP + Query Loop for Woocommerce products (Not the Products widgets) in an archive page?
I have the filters correctly displayed with the right numbers, but when I filter the products are not filtered.

@pedronx

For Query Loops with WooCommerce products I use this and it works for Product Archive Template, at least for me.

/**
 * Using Facet WP for filtering Archive Page
 */
add_filter( 'facetwp_template_use_archive', '__return_true' );

add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
  if ( $query->is_archive() && $query->is_main_query() ) {
    $is_main_query = false;
  }
  return $is_main_query;
}, 10, 2 );

Please refers to this for more updated info:
https://facetwp.com/help-center/developers/hooks/querying-hooks/facetwp_template_use_archive/