• Resolved Libbieloo

    (@libbieloo)


    Hello!

    I’ve seen a few posts about this but I need help with the CSS.

    I’d like to hide/remove the navigation bar from the home page only.

    My research says the easiest way is to use CSS, but I’m having trouble figuring out exactly where the code goes in the stylesheet file, and what code goes in the php file (header.php, I assume).

    body.page-id-5 #menu {display:none;}

    This is as far as I got, but I don’t know what to do with it (and how to execute it).

    Can anyone help with this basic css question?

    (URL is https://mnscleaning.ca/)

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can add something like this to the top of your index.php (or whatever your homepage is)

    <style>#access { display:none; }</style>

    Note: There are multiple ways this can be accomplished, but this is the quick and dirty way.

    You can also include something like this in your header.php file

    <?php if ( is_home() ) {
     echo'<style>#access {display:none}</style>';
    } else {
    
    } ?>

    You can also add something like this to your function.php file

    <?php
    function remove_navigation_from_homepage() {
       if ( is_home() ) {
     echo'<style>#access {display:none}</style>';
    } else {
    
    }
    ?>
    add_action ('wp_head','remove_navigation_from_homepage')

    Thread Starter Libbieloo

    (@libbieloo)

    Thank you so much!! I have been trying all three of those paths all day, just couldn’t get the syntax quite right. Even with your help, only the <style> code added to the template finally worked for me. The header edit had no effect, and the functions file is so picky! It gives me nothing but error messages.

    But anyway… it seems to be working now. Thanks again!

    Libbie

    Great, I’m glad one of the three methods were able to work for you! Have a wonderful afternoon and Happy Coding!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remove menu/nav bar on just one page?’ is closed to new replies.