Menu com Scroll to #section - Bug "top is not defined" -> Quando existe um menu de Landing Page com outras páginas. Ex: Páginas internas etc
/*==============================
= Scroll =
==============================*/
$('#menu-menu-principal a').click(function( event ){
event.preventDefault();
var e = $('#menu-menu-principal').data("home"),
i = $(this).attr("href").indexOf("#") === -1;
if (i) return window.location.href = $(this).attr("href");
if ("no" == e && !i) {
var s = $(this).attr("href").indexOf("#");
return s = $(this).attr("href").substr(s), window.location.href = $('#menu-menu-principal').data("url") + s
}
var n = $(this.hash).offset().top - 80;
$("html,body").animate({
scrollTop: n
}, 800)
});
/*===== End of Scroll ======*/
<ul data-url="<?=home_url()?>" data-home="<?= ( is_home() ) ? 'yes' : 'no'?>" id="menu-menu-principal" class="">
<li><a href="<?php echo home_url(); ?>#home">Home</a></li>
<li><a href="<?php echo home_url(); ?>#nome2">Nome2</a></li>
</ul>