0

I am using the WP- Spirit 01 theme and would like to know how can I hide the navigation menu ONLY from the website homepage. I don't have my website live yet. The css code bellow works to hide the menu everywhere not the homepage.

.drop-down ul{
    display:none;
}

Will be very thankful and happy if someone helps me as soon as possible!

2

You should be able to short circuit the menu by conditionally returning an empty string by adding this code to your theme functions.php :

add_filter( 'pre_wp_nav_menu', 'wpse_210095');
function wpse_210095($menu) {
  if (is_home()) {
   $menu = '';
  }
  return $menu;
}

You can see in the Core where this logic executes:

260         $nav_menu = apply_filters( 'pre_wp_nav_menu', null, $args );
261 
262         if ( null !== $nav_menu ) {
263                 if ( $args->echo ) {
264                         echo $nav_menu;
265                         return;
266                 }
267 
268                 return $nav_menu;
269         }
  • What to do in order to have the menu showing on phone view? Thank you. – Zorica Petkovik Nov 27 '15 at 19:27
  • I'd have to look through the theme to see how "mobile" is being managed and I don't have time for that. – s_ha_dum Nov 27 '15 at 19:31
  • It's worth pointing out something about is_home(). ` * If a static page is set for the front page of the site, this function will return true only * on the page you set as the "Posts page".` – crmpicco Sep 14 '17 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.