Skip to content

Instantly share code, notes, and snippets.

@djrmom
Created August 20, 2020 18:36
Show Gist options
  • Save djrmom/d856a457f419130d55dec3074d2940d2 to your computer and use it in GitHub Desktop.
Save djrmom/d856a457f419130d55dec3074d2940d2 to your computer and use it in GitHub Desktop.
facetwp woocommerce 4.4.0 pagination fix
<?php
/** fix for woocommerce pagination not updated during facet refresh **/
add_action( 'pre_get_posts', function( $query ) {
if ( true === $query->get( 'facetwp' ) && 'product_query' == $query->get( 'wc_query' ) ) {
$prefix = FWP()->helper->get_setting( 'prefix' );
$name = $prefix . 'paged';
// Set the paged var
if ( isset( FWP()->facet->http_params['get'][ $name ] ) ) {
set_query_var( 'paged', (int) FWP()->facet->http_params['get'][ $name ] );
}
}
}, 1000 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment