FacetWP – ignore WC REST API queries

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

// Add to your (child) theme’s functions.php
// woocommerce_rest_{$this->post_type}_object_query

add_filter( ‘facetwp_is_main_query’, function( $is_main_query, $query ) {
if ( false !== strpos( $_SERVER[‘REQUEST_URI’], ‘wp-json/wc/v3’ ) ) {
$is_main_query = false;
}
return $is_main_query;
}, 10, 2 );

/*
add_filter( ‘woocommerce_rest_product_object_query’, function( $args ) {
$args[‘facetwp’] = false;
return $args;
});
*/
{{/gist}}