Created
August 20, 2020 18:36
-
-
Save djrmom/d856a457f419130d55dec3074d2940d2 to your computer and use it in GitHub Desktop.
facetwp woocommerce 4.4.0 pagination fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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