Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Created March 26, 2020 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgibbs189/5a031f12fcace59ea4ee3da9fcd78669 to your computer and use it in GitHub Desktop.
Save mgibbs189/5a031f12fcace59ea4ee3da9fcd78669 to your computer and use it in GitHub Desktop.
FacetWP - get hash clicks working
<?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