Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Last active October 19, 2020 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgibbs189/00ccc6c95e00272111e39803324aaf80 to your computer and use it in GitHub Desktop.
Save mgibbs189/00ccc6c95e00272111e39803324aaf80 to your computer and use it in GitHub Desktop.
FacetWP - ignore WC REST API queries
<?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;
});
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment