• Resolved EMRETHEAVIATOR

    (@emretheaviator)


    Hi Richie. Thank you for this great theme.

    I need to hide Main Menu on pages except for Homepage and Blog Page and Category Pages of Blog .I have looked previous topics but I couldn’t find an answer.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Theme Author Richie KS

    (@rkcorp)

    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.

    Thread Starter EMRETHEAVIATOR

    (@emretheaviator)

    <?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

    Thread Starter EMRETHEAVIATOR

    (@emretheaviator)

    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

    Thread Starter EMRETHEAVIATOR

    (@emretheaviator)

    I just don’t want main menu on irrelevant pages like bbpress, buddypress and woocommerce pages.

    Theme Author Richie KS

    (@rkcorp)

    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');
    Theme Author Richie KS

    (@rkcorp)

    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');
    Thread Starter EMRETHEAVIATOR

    (@emretheaviator)

    I modified the code as is_page removing is_home and is_archieve

    But this time main menu

    Can you help me Richie.

    Thread Starter EMRETHEAVIATOR

    (@emretheaviator)

    The last code you give me does something different Richie.

    Thread Starter EMRETHEAVIATOR

    (@emretheaviator)

    `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.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Hiding Main Menu’ is closed to new replies.