• Resolved ViPeRx007

    (@viperx007)


    The site I am working on is here:
    https://www.redlodgerestaurants.com

    It’s easiest to explain what I’m trying to do by showing, so if you go to the site, click “Red Lodge Pizza Co.”, then “Delivery” that page shows the menu working exactly as I want. Notice the top level “Red Lodge Pizza Co.” is active. I can’t get it to do that on the main parent pages though.

    If you just click “Red Lodge Pizza Co.” everything works but the main parent item isn’t active.

    Hopefully this makes sense. I’m sure this is just a style I’m not doing right. I appreciate your help.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Try changing:

    #leftNav .current_page_parent > a {
        background-image: url("../img/nav-rollover.png");
        background-position: -3px 50%;
        background-repeat: no-repeat;
        color: #ECE4CD;
    }

    in site.css to:

    #leftNav .current_page_parent > a,
    #leftNav .current_page_item > a {
        background-image: url("../img/nav-rollover.png");
        background-position: -3px 50%;
        background-repeat: no-repeat;
        color: #ECE4CD;
    }
    Thread Starter ViPeRx007

    (@viperx007)

    esmi, saving the day again!

    That fixes a majority of my problem but is there a way to apply a separate active state for the submenus?

    See here:
    https://www.redlodgerestaurants.com/red-lodge-pizza-company/delivery/

    This looks a little weird with “Delivery” active in that way.

    You need to “reset” the colours for the active item in a sub-menu using something like:

    #leftNav li .current_page_item > a {
    background-image: none;
    background-color: #EEE4CF;
    color: #261F1A;
    }
    Thread Starter ViPeRx007

    (@viperx007)

    Arg! I was close. I was trying this (and others similar..to no avail):
    #leftNav ul li.current_page_item > a

    Using what you suggested did the trick. Once again, thanks esmi!

    No problem. By the way, your main menu doesn’t have <ul></ul> tags. You might want to fix that in case it bites back at a later date.

    Thread Starter ViPeRx007

    (@viperx007)

    Hmm. If I put <ul> tags in the menu it doesn’t work as I want it to. It starts displaying flyouts. My menu is generated using the follow php code:

    <div id="leftNav" class="menu">
    <?php 
    
    $Pages      = wp_list_pages('title_li=&echo=0&depth=1');
    $InnerPages = wp_list_pages('child_of='.($post->post_parent != false ? $post->post_parent : $post->ID).'&title_li=&echo=0');
    $Title      = ($post->post_parent != false) ? trim(get_the_title($post->post_parent)) : trim(wp_title('', false));
    if($Title != '')
      $Pages      = str_replace($Title.'</a></li>',
                                $Title.'</a>'.
                                '<ul>'.$InnerPages.'</ul></li>',
                                $Pages);
    echo $Pages;
    unset($Pages, $InnerPages);
    
    ?>
        <div style="clear:both"></div>
    </div>

    You really need those ul tags in there as, otherwise, you’re generating markup validation errors that could cause display issues in some browsers. Try:

    <div id="leftNav" class="menu"><ul>
    [ ... ]
    </ul></div>
    Thread Starter ViPeRx007

    (@viperx007)

    I did that and now the menus are displaying as flyouts instead of inline as they previously were.

    That’s because you have unwanted CSS in site.css. You need to recheck all of the #leftNav ul ul rules. You might also want to look at replacing the code above with a jQuery accordion script to get the dropdown effect. If you have a look at some of my themes (with the exception of ZenLite), you’ll find a accordion js script and CSS that you should be able to adapt for your use.

    Thread Starter ViPeRx007

    (@viperx007)

    Thanks for the suggestion. I prefer accordion menus but this client specifically requested a menu like the one on this site so I’m just trying to please the masses:

    https://cityofredlodge.com/

    Anyway, I cleaned up that CSS and got the menu displaying correctly again. Actually it looks better now than it did because some of my styles were being blocked by old ones generated by WP.

    I’m really not a newbie at this stuff, though it might seem that way. Somehow I always seem to get stuck on things that end up being relatively easy.

    Thanks again!

    Isn’t the menu you have essentially an accordion menu? What’s the difference?

    [EDIT] Didn’t mean to imply that you were a new bug, btw. I did recognise your username. I was just trying to think of different approaches that might help.

    Thread Starter ViPeRx007

    (@viperx007)

    No, I wasn’t meaning that you were treating me like a newbie, I was just referring to the issues I’ve come in here requesting help on. They haven’t been super complicated things, just things I overlook.

    Regarding the menu, I suppose it is an accordion. I guess I tend to think of accordion menus as the ones that slide open and closed without changing the page, whereas this one is just displays a menu on the new page.

    Again, I don’t want to over-analyze this one as it’s doing what my client wants so I’ll leave it at is for now.

    Thanks for the help as usual, esmi. You’re the only one who’s helped me on this site. Of course I’ve only come for two issues….so far.

    No problem ??

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Menu Issue: Keeping parent item active throughout child navigation’ is closed to new replies.