Skip to content

Instantly share code, notes, and snippets.

@hrenaud
Last active December 12, 2020 11:40
Show Gist options
  • Select an option

  • Save hrenaud/14637895e24a521c524b0cdfd136c441 to your computer and use it in GitHub Desktop.

Select an option

Save hrenaud/14637895e24a521c524b0cdfd136c441 to your computer and use it in GitHub Desktop.
add_action('wp_footer', function () {
if (!defined('ELEMENTOR_VERSION')) {
return;
}
?>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
$header_height = $(".elementor-location-header").css('height');
if (typeof $header_height === "undefined") {
$header_height = $("header").css('height');
}
$adminbar_height = $("#wpadminbar").css('height');
if (typeof $adminbar_height === "undefined") {
$value = $header_height;
} else {
$value = (parseInt($header_height.replace(/px/, "")) + parseInt($adminbar_height.replace(/px/, ""))) + "px"
}
$(".elementor-section").css("scroll-margin-top", $value);
});
})(jQuery);
</script>
<?php
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment