Hiding Main Menu
-
add this to child theme functions.php or wp-content/meso-custom-functions.php if had one.
function meso_header_condition() { global $post; if( is_home() || is_archive() ) { echo '<style id="remove-nav">#main-navigation{display:none;}</style>'; } } add_action('wp_head','meso_header_condition');Hello … would like do the same, but hide it only in Home page.
Please could you tell me the variant of the code?
Thank your very much in advance.
<?php
function meso_load_child_style() {
global $theme_version;
wp_enqueue_style( ‘meso-child-css’, get_stylesheet_directory_uri() . ‘/style.css’, array(), $theme_version );
}
add_action( ‘wp_enqueue_scripts’, ‘meso_load_child_style’,99 );
?><?php
function meso_header_condition() {
global $post;
if( is_home() || is_archive() ) {
echo ‘<style id=”remove-nav”>#main-navigation{display:none;}</style>’;
}
}
add_action(‘wp_head’,’meso_header_condition’);
?>Is it right Richie. I am not sure. I do not want to crash the website. Thank you
Hi Richie
I added the code with single opening php tag.I did not use a closing tag.
The code did something reverse. I need to keep main menu on
homepage,
blog page and
archieve pages.The code removed main menu from
homepage
archieve pages and
shopping page-
This reply was modified 9 years, 7 months ago by
EMRETHEAVIATOR.
-
This reply was modified 9 years, 7 months ago by
EMRETHEAVIATOR.
I just don’t want main menu on irrelevant pages like bbpress, buddypress and woocommerce pages.
try this
function meso_header_condition() { global $in_bbpress, $bp_active; if( (function_exists('is_in_woocommerce_page') && is_in_woocommerce_page()) && $bp_active == 'true' && $in_bbpress == 'true' ) { echo '<style id="remove-nav">#main-navigation{display:none;}</style>'; } } add_action('wp_head','meso_header_condition');Hello … would like do the same, but hide it only in Home page.
Please could you tell me the variant of the code?
Thank your very much in advance.function meso_header_condition() { global $post; if( is_home() && is_front_page() ) { echo '<style id="remove-nav">#main-navigation{display:none;}</style>'; } } add_action('wp_head','meso_header_condition');I modified the code as is_page removing is_home and is_archieve
But this time main menu
-
does not apper on blog page
appear on shopping page that I don’t want.
Can you help me Richie.
The last code you give me does something different Richie.
`function meso_header_condition() {
global $post;
if( is_woocommerce() || is_page() ) {
echo ‘<style id=”remove-nav”>#main-navigation{display:none;}</style>’;
}
}
add_action(‘wp_head’,’meso_header_condition’);It is acceptable for me. Thank you Richie.
-
This reply was modified 9 years, 7 months ago by
The topic ‘Hiding Main Menu’ is closed to new replies.
