Created
March 26, 2020 23:51
-
-
Save mgibbs189/5a031f12fcace59ea4ee3da9fcd78669 to your computer and use it in GitHub Desktop.
FacetWP - get hash clicks working
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 | |
// Add the following to your (child) theme's functions.php | |
add_action( 'wp_footer', function() { | |
?> | |
<script> | |
(function($) { | |
$(document).on('click', 'a[href^="#"]', function() { | |
var css_id = $(this).attr('href'); | |
var $el = $(css_id); | |
if (0 < $el.length) { | |
window.scrollTo(0, $el.offset().top); | |
} | |
}); | |
})(jQuery); | |
</script> | |
<?php | |
}, 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment