WordPress.org

Ready to get started?Download WordPress

Forums

dynamic menu highlighting with a unique problem/twist (1 post)

  1. xiabolai
    Member
    Posted 4 years ago #

    Hi,

    Have a tricky problem I can't solve, hoping someone can help. I'm trying to dynamically highlight the parent menu item based on what child submenu item is selected below it. Also, if a post is selected under the subcategory, I'd like the top level parent menu item to stay highlighted.

    But here's the unique problem/twist: the template I'm using has the top level parent item a non-link and not a category, and the submenu items are the categories.

    Here's that code from my header:

    <li><a>Work</a>
    
        		<ul>
        			<?php wp_list_categories("exclude=$blog_ID&title_li="); ?>
        		</ul>
        	</li>

    So in this scenario, when you roll over "Work" in the menu, work is not clickable, but you get a drop down submenu with clickable category links, like interactive, email, print, etc. That's just how the template I'm using is set up.

    I know how to make the single Home, About and Contact pages dynamically highlight, here's the php and css I'm using for those:

    php:

    <li<?php
                    if (is_page('About'))
                    {
                    echo " id=\"current\"";
                    }?>>
                    <a href="<?php bloginfo('url') ?>/about">About</a>
            </li>

    css:

    #current a {font-weight:bold;color:#e2007d;}

    I've played around with the "Work" parent and submenu and have it partially working, but now when a child submenu item is selected, all of the child submenu items stay highlighted...you'll see the problem here on my test site:

    http://www.newsite.blairshapiro.com

    Again, it should be that only the parent menu item, "Work," stays highlighted when one of the child submenu items OR one of the posts belonging to the particular submenu child is selected. I hope that's clear.

    Any help would be appreciated.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic