Skip to content

Instantly share code, notes, and snippets.

@jb510
Last active January 16, 2022 02:53
Show Gist options
  • Save jb510/e7e137ca6fb92b4647f070e6b6900006 to your computer and use it in GitHub Desktop.
Save jb510/e7e137ca6fb92b4647f070e6b6900006 to your computer and use it in GitHub Desktop.
FacetWP Scroll to Top on Pagination
// Add FacetWP scroll to top of content on pagination
add_action('wp_head','s9_scroll_to_top_on_pagination');
function s9_scroll_to_top_on_pagination() {
echo <<<END
<script>
(function($) {
$(document).on('facetwp-refresh', function() {
if ( FWP.soft_refresh == true ) {
FWP.enable_scroll = true;
} else {
FWP.enable_scroll = false;
}
});
$(document).on('facetwp-loaded', function() {
if ( FWP.enable_scroll == true ) {
$('html, body').animate({
scrollTop: $('.content-sidebar-wrap').offset().top - 25
}, 500);
}
});
})(jQuery);
</script>
END;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment