admin管理员组文章数量:1334297
TheHamburgerCollection
My hamburger menu is working correctly on all other pages - I just don't want it to display on the home page, where it's visible at 768px and below.
footer.php is where the menu is located:
<div class="mobile-nav">
<div class="menu-btn" id="menu-btn">
<div></div>
<span></span>
<span></span>
<span></span>
</div>
<div class="responsive-menu">
<?php
if ( ! is_front_page() && ! is_home() ) {
wp_nav_menu();
}
?>
</div>
</div>
You can see that I've told it not to display the nav menu on the front page (also the home page), and it's doing this correctly - but how do I do the same thing to the hamburger menu?
I followed the instructions in this tutorial to create my hamburger menu. If I try to copy the if statement that's telling the browser to display the Nav Menu on all other pages besides the Front Page / Home Page and then paste it just before the div with a class and id "menu-btn"
, I get a syntax error:
<div class="mobile-nav">
<?php if ( ! is_front_page() && ! is_home() ) {
<div class="menu-btn" id="menu-btn">
<div></div>
<span></span>
<span></span>
<span></span>
</div>
?>
<div class="responsive-menu">
<?php
if ( ! is_front_page() && ! is_home() ) {
wp_nav_menu();
}
?>
</div>
</div>
I'm not sure if there's a way to hide the hamburger menu on a specific page with CSS, or if I do need to use PHP or JS, where should I place the function / what function should I use?
Thank you!
TheHamburgerCollection
My hamburger menu is working correctly on all other pages - I just don't want it to display on the home page, where it's visible at 768px and below.
footer.php is where the menu is located:
<div class="mobile-nav">
<div class="menu-btn" id="menu-btn">
<div></div>
<span></span>
<span></span>
<span></span>
</div>
<div class="responsive-menu">
<?php
if ( ! is_front_page() && ! is_home() ) {
wp_nav_menu();
}
?>
</div>
</div>
You can see that I've told it not to display the nav menu on the front page (also the home page), and it's doing this correctly - but how do I do the same thing to the hamburger menu?
I followed the instructions in this tutorial to create my hamburger menu. If I try to copy the if statement that's telling the browser to display the Nav Menu on all other pages besides the Front Page / Home Page and then paste it just before the div with a class and id "menu-btn"
, I get a syntax error:
<div class="mobile-nav">
<?php if ( ! is_front_page() && ! is_home() ) {
<div class="menu-btn" id="menu-btn">
<div></div>
<span></span>
<span></span>
<span></span>
</div>
?>
<div class="responsive-menu">
<?php
if ( ! is_front_page() && ! is_home() ) {
wp_nav_menu();
}
?>
</div>
</div>
I'm not sure if there's a way to hide the hamburger menu on a specific page with CSS, or if I do need to use PHP or JS, where should I place the function / what function should I use?
Thank you!
Share Improve this question asked Nov 23, 2016 at 4:45 SpeakInCode43SpeakInCode43 1112 bronze badges 2- use this plugin wordpress/plugins/page-specific-menu-items it allows you to select menu items page wise. – GKS Commented Nov 23, 2016 at 4:47
- Do you know if allows you to select whether or not to display a hamburger menu, though? – SpeakInCode43 Commented Nov 23, 2016 at 4:59
1 Answer
Reset to default 1You're getting a syntax error because you forgot to close off your first if. Also, you need to close off the first php block.
<div class="mobile-nav">
<?php if ( ! is_front_page() && ! is_home() ) { ?>
<div class="menu-btn" id="menu-btn">
<div></div>
<span></span>
<span></span>
<span></span>
</div>
<?php } // <-- You forgot to put this in ?>
<div class="responsive-menu">
<?php
if ( ! is_front_page() && ! is_home() ) {
wp_nav_menu();
}
?>
</div>
</div>
本文标签: phpHide Hamburger Menu On Specific Page (Front PageHome Page)
版权声明:本文标题:php - Hide Hamburger Menu On Specific Page (Front PageHome Page) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742252464a2441018.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论