我去了GeneratePress网站,查看了他们的一个演示:
<nav id="site-navigation" class="main-navigation sub-menu-left" itemtype="https://schema.org/SiteNavigationElement" itemscope>
<div class="inside-navigation">
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
<span class="mobile-menu">Menu</span>
</button>
<div id="primary-menu" class="main-nav">
<ul id="menu-menu-1" class=" menu sf-menu">
<li id="menu-item-594520" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home menu-item-594520"><a href="https://generatepress.com/">area riservata</a></li>
<li id="menu-item-594521" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-594521"><a href="https://generatepress.com/premium/">Premium</a></li>
</ul>
</div>
</div><!-- .inside-navigation -->
</nav><!-- #site-navigation -->
因此,在函数的PHP中,可以尝试删除以下内容:
function change_area_riservata_url() { ?>
<script type="text/javascript">
jQuery( document ).ready( function($) {
<?php if( is_user_logged_in() ) : ?>
var hrefAtt = \'https://google.com\'; //the URL if user is logged in
<?php else : ?>
var hrefAtt = \'https://bing.com\'; //the URL if NOT logged in
<?php endif; ?>
//Make sure the correct ID is in place
$( \'#menu-item-594520 a\' ).attr( \'href\', hrefAtt );
} );
</script>
} ?>
add_action( \'generate_after_header\', \'change_area_riservata_url\', 20 );
显然,您需要编辑URL和菜单项的ID,以便它与您的站点相匹配。