Support » Themes and Templates » Highlighting Child Pages

  • Ok, so I’m sure that this is a relatively simple problem with an equally simple solution, but I’m stuck. I’m building a site that has a static home page with the blog page as a menu item. Pretty straight forward.

    The problem is that the blog page menu item is only assigned the class “current-menu-item” when currently clicked on it and WordPress is using the “index.php” file. Once a post is clicked and WordPress begins using the “single.php” file, that class no longer is assigned to the menu item, thereby not allowing it to be highlighted as the active menu item.

    I’ve read plenty of solutions that use conditional statements to determine if a page is a child page or not, but the problem I’m facing is that I’m using the WordPress 3.0 menu option in the GUI, which means that my navigation is being dynamically created.

    My question is this: How can I get the “blog” link to be the .current-menu-item when WordPress is using single.php, category.php, tag.php, etc. while still using the GUI menu system and not hardcoding in my navigation?

    Any help would be greatly appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi


    Forum Moderator

    I encountered this the other day and worked around it by adding a custom class to body_class() in header.php based in is_single() etc. Then I added CSS to replicate the current-menu-item highlighting via .body.single.custom-class

    Thanks for the quick response!

    I’m not sure I’m exactly following though. Do you think you could possibly post the code?


    Ok, for anyone who comes across this I’ve figured it out (and feel quite sheepish, to be honest).

    It’s as simple as using .current_page_parent for regular pages that have parentage and .current_page_ancestor for blog pages. I had read this elsewhere and must not have understood that these classes are dynamically generated by WordPress, so there you go.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Highlighting Child Pages’ is closed to new replies.