Forums

Sub menu Parent highlighting (5 posts)

  1. cheriejd
    Member
    Posted 3 years ago #

    I have a site that is using sub menus on some pages, but not on the sub pages.

    I would like to have the parent item in the menu always highlighted as current page, even if I am on a child page of that page.

    I am using the Andreas theme. This is the line in the functions.php that highlights the current page item
    <?php if (is_page()) { $highlight = "page_item"; } else {$highlight = "page_item current_page_item"; } ?>

    I thought it might be
    <?php if (is_page() | is_child()) { $highlight = "page_item"; } else {$highlight = "page_item current_page_item"; } ?>
    but that isn't working.

    So, basically, in main menu which only shows parent pages, I would like the parent to remain in the current_page_item state if one of their children is showing.

    thanks in advance

  2. elephantseeselephant
    Member
    Posted 2 years ago #

    I'm dealing with exactly the same problem. Anyone?

  3. Technokinetics
    Member
    Posted 2 years ago #

    List items containing parent pages should have the classes "current_page_parent" and "current_page_ancestor". In your theme's stylesheet, you just need to style .current_page_ancestor (or perhaps .current_page_ancestor a) in whatever way .current_page_item (or .current_page_item a) is already styled.

    - Tim

  4. stwief
    Member
    Posted 2 years ago #

    That's great! I've been looking all over the internet. I never would have thought there would be a solution that simple... Well, you proved me wrong! Thanks!

  5. Casemon
    Member
    Posted 2 years ago #

    Similar topic, with solution, if it helps:

    http://wordpress.org/support/topic/296283

Topic Closed

This topic has been closed to new replies.

About this Topic