R
R
racheer2019-10-16 18:08:48
User navigation
racheer, 2019-10-16 18:08:48

How to hide the menu on a specific page in WP?

Hide the main menu on a specific page of a WordPress site. A la code

if(!is_page(100) && !is_page(200) && !is_page(300)) {
    get_template_part('primer');
} else {
    get_template_part('none');
}

found on the same toaster, turns the site into some kind of hodgepodge, although it is marked with a solution. How to be?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Gleb Varganov, 2019-10-16
@kores

Most likely, your menu is displayed via wp_nav_menu( [ 'menu' => 'Навигация' ] );
If you need to hide, for example, on a page with ID 100, then the code will be something like this:

if ( is_page(100) ) {
  // Это страница с ID 100
  // Ничего не показываем
} else {
  // Это страница НЕ с ID 100
  // Показываем меню
  wp_nav_menu( [ 'menu' => 'Навигация' ] );
}

T
tuxfighter, 2019-10-17
@tuxfighter

with css

body.page-100 nav{
display: none;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question