Josefine Posted October 8, 2015 Share Posted October 8, 2015 Hi, need some help to hide / remove the wp_nav_menu from my index page. I'm using the the Tesseract theme, nav_menu is located in the header I got a advice to commenting out the code, but I just don't seem to get it right. <?php $anyMenu = get_terms( 'nav_menu' ) ? true : false; $menuSelect = get_theme_mod('tesseract_tho_header_menu_select'); if ( $anyMenu && ( ( $menuSelect ) && ( $menuSelect !== 'none' ) ) ) : wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'header-menu' ) ); elseif ( $anyMenu && ( !$menuSelect || ( $menuSelect == 'none' ) ) ) : $menu = get_terms( 'nav_menu' ); $menu_id = $menu[0]->term_id; wp_nav_menu( array( 'menu_id' => $menu_id ) ); elseif ( !$anyMenu ) : wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); endif; ?> Thank you in advance for any kind of help! / Jo' Quote Link to comment https://forums.phpfreaks.com/topic/298491-how-to-remove-wp_nav_menu-from-a-page/ Share on other sites More sharing options...
QuickOldCar Posted October 9, 2015 Share Posted October 9, 2015 I usually make plugins to add or remove certain things if(is_front_page() || is_home()){ if (function_exists('wp_nav_menu')) { remove_action('wp_head', 'wp_nav_menu'); } } In your case wrap the code you have with a check for not home or front page <?php if(!is_front_page() && !is_home()){ $anyMenu = get_terms( 'nav_menu' ) ? true : false; $menuSelect = get_theme_mod('tesseract_tho_header_menu_select'); if ( $anyMenu && ( ( $menuSelect ) && ( $menuSelect !== 'none' ) ) ) : wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'header-menu' ) ); elseif ( $anyMenu && ( !$menuSelect || ( $menuSelect == 'none' ) ) ) : $menu = get_terms( 'nav_menu' ); $menu_id = $menu[0]->term_id; wp_nav_menu( array( 'menu_id' => $menu_id ) ); elseif ( !$anyMenu ) : wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); endif; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/298491-how-to-remove-wp_nav_menu-from-a-page/#findComment-1522777 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.