Last active
December 16, 2020 17:53
-
-
Save djrmom/e9aa50d4988a1b5b57a6ecbc648b5333 to your computer and use it in GitHub Desktop.
facetwp scrollTop example with wp_head hook
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 | |
/** adds script to header | |
** https://facetwp.com/how-to-add-pagination-scrolling/ | |
**/ | |
add_action( 'wp_head', function() { ?> | |
<script> | |
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
if (FWP.loaded) { | |
$('html, body').animate({ | |
scrollTop: $('.facetwp-template').offset().top | |
}, 500); | |
} | |
}); | |
})(jQuery); | |
</script> | |
<?php } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment