WordPress.org

Ready to get started?Download WordPress

Forums

Dynamic menu highlighting with child-of-child pages (1 post)

  1. david.danaan
    Member
    Posted 3 years ago #

    I'm using the solution described here to dynamically highlight top-level pages and their child pages: http://www.darrenhoyt.com/2008/02/12/creating-two-tiered-conditional-navigation-in-wordpress/

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

    The dynamic highlighting works great for the page and child page, but when on a child-of-child page, although the current page is highlighted, only the child-of-child level is displayed and the top-level page is not highlighted. What I want is for both levels of the sidebar menu to display, with the current page and the appropriate top-level page highlighted.

    The code I'm using is below. I've tried adding depth parameters, but that doesn't seem to be the answer. Can anyone tell me how to fix this? I'm sorry I don't have a link - this is a site under development on my localhost. Many thanks in advance for help.

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

Topic Closed

This topic has been closed to new replies.

About this Topic