WordPress.org

Ready to get started?Download WordPress

Forums

Dynamic highlighting and grandchild pages (1 post)

  1. Modriguez
    Member
    Posted 6 years ago #

    Hi folks, I've been trying to generate a dynamically populated menu which dynamically highlights the current page when you call up the parent page's children and grandchild. So far I've got it working for child pages, but when I drop down to the grandchild level the highlighting goes away. Here's the code I'm working with, any idea how I can tweak it to do what I want?

    <?php if (is_page()) { $highlight = "page_item"; } else {$highlight = "page_item current_page_item"; } ?>
    
    <ul><li class="<?php echo $highlight; ?>"><a href="<?php bloginfo('url'); ?>">Home</a></li>
    <?php wp_list_pages('sort_column=menu_order&title_li') ?></ul>

    Thanks a lot!

Topic Closed

This topic has been closed to new replies.

About this Topic