WordPress.org

Ready to get started?Download WordPress

Forums

Dynamic menu highlighting with 3 levels (3 posts)

  1. david.danaan
    Member
    Posted 4 years ago #

    To have both a top-level page link and its subpage link highlighted dynamically, I'm using the solution described here: http://www.darrenhoyt.com/2008/02/12/creating-two-tiered-conditional-navigation-in-wordpress/

    I have a top-level horizontal menu, with subpages in custom sidebars for each top-level page. Some of those subpage menus are nested with two levels.

    The highlighting works great, except that when on a child-of-child page I would like for both levels of the subpage menu (ul ul li) to display in the sidebar with the current page highlighted. What I have is just the third level (ul li).

    Here's the code:

    <?php if($post->post_parent)
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");  
    
    if ($children && is_page()) { ?>
    <ul>
    <?php echo $children; ?>
    </ul>
    <?php } else { ?>
    <?php } ?>

    Help?

  2. david.danaan
    Member
    Posted 4 years ago #

    Also, when on a child-of-child page the top-level parent link isn't highlighted either, just the current page link.

    I tried adding various &depth= parameters, but nothing has worked so far.

  3. david.danaan
    Member
    Posted 4 years ago #

    bump..

    There has got to be a ridiculously common solution to this - I'm just not proficient enough to see what it is. Many thanks in advance.

Topic Closed

This topic has been closed to new replies.

About this Topic