Skip to content

Instantly share code, notes, and snippets.

@djrmom
Created October 29, 2018 21:10
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save djrmom/971940882f87a5ce0bdcdfd83ae8a9ae to your computer and use it in GitHub Desktop.
Save djrmom/971940882f87a5ce0bdcdfd83ae8a9ae to your computer and use it in GitHub Desktop.
facetwp conditional scroll to top only on pager
<?php
/** scoll on loaded only if pager is the change in facet **/
add_action( 'wp_head', function() { ?>
<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: 0 }, 500);
}
});
})(jQuery);
</script>
<?php } );
@Mictu
Copy link

Mictu commented Sep 5, 2019

How do I custimize this code to a specific page? I want that some pages only scroll to a certain point and on default to top

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment