Skip to content

Instantly share code, notes, and snippets.

@jin0x
Forked from mgibbs189/functions.php
Last active November 8, 2018 00:21
Show Gist options
  • Save jin0x/bf28272c22e86b828b20bf8f34897a1e to your computer and use it in GitHub Desktop.
Save jin0x/bf28272c22e86b828b20bf8f34897a1e to your computer and use it in GitHub Desktop.
FacetWP - pager handler
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