Last active
January 16, 2022 02:53
-
-
Save jb510/e7e137ca6fb92b4647f070e6b6900006 to your computer and use it in GitHub Desktop.
FacetWP Scroll to Top on Pagination
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
// 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