-
-
Save jin0x/bf28272c22e86b828b20bf8f34897a1e to your computer and use it in GitHub Desktop.
FacetWP - pager handler
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
function fwp_pager_handler() { | |
?> | |
<script> | |
(function($) { | |
$(document).on('facetwp-refresh', function() { | |
if (! FWP.loaded) { | |
$(document).on('click', '.pagination a', function(e) { | |
e.preventDefault(); | |
var matches = jQuery(this).attr('href').match(/\/page\/(\d+)/); | |
if (null != matches) { | |
FWP.paged = parseInt(matches[1]); | |
} | |
FWP.soft_refresh = true; | |
FWP.refresh(); | |
}); | |
} | |
}); | |
})(jQuery); | |
</script> | |
<?php | |
} | |
add_action( 'wp_footer', 'fwp_pager_handler', 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment