facetwp woocommerce archive only facets

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/** for sites that only use facets on woocommerce archive pages –
** shop page, product category archives, product tag archives,
** any others auto-created by woocommerce
** not for [product] shortcode or custom queries
**/

add_filter( ‘facetwp_is_main_query’, function( $is_main_query, $query ) {
if ( ‘product_query’ != $query->get( ‘wc_query’ ) ) {
$is_main_query = false;
}
return $is_main_query;
}, 10, 2 );
{{/gist}}