Highlight Parent Menu Item while in Child Page (7 posts)

  1. harman79
    Posted 2 years ago #

    Hi all,

    I have the free reponsive wordpress theme and I have come across something I cannot resolve via CSS. What I want to do is have the parent menu item retain its active color while the user views a child page. To be more specific here is an example.

    We have a page say called Company. This page has a menu item in the main nav menu. There is a number of pages setup as children to this page in wordpress backend but DO NOT have any menu items. What I want is that when somebody is viewing any of these pages the menu item of the Company page to remain with active color.

    I have tried all CSS ways I have found around but nothing works. I have listed all CSS tried below.

    .menu .current_page_item a,
    .menu .current-menu-item a,
    .menu .current_page_parent a,
    .menu .current_page_ancestor a,
    .menu .current-menu-parent a,
    .menu .current-menu-ancestor a {
    	background-color: #343434;

    Any suggestions anyone?

    Thanks a lot.


  2. esmi
    Forum Moderator
    Posted 2 years ago #

    As per the theme developer's request, please post in the theme's dedicated forum: http://cyberchimps.com/forum/

  3. harman79
    Posted 2 years ago #


    OK thanks for the info. Doing this now.


  4. Bibiano Wenceslao
    Posted 1 year ago #

    I just insert the following code in the theme’s footer.php file right before the closing body tag </body>.

    <!-- Highlight parent page link when on child page -->
    <?php if (is_page()) {   //  displaying a child page ?>
        <script type="text/javascript">
    <?php } ?>

    Simply put, the code adds another native WordPress nav li class that makes the link of the current page active.

    For a detailed explanation of how this works I wrote a short post here; [link moderated]

    Hope that helps!

  5. WPyogi
    Forum Moderator
    Posted 1 year ago #

    @bibianowency - please note that posting links to your site is not the purpose of these forums - http://codex.wordpress.org/Forum_Welcome#Link_to_Your_Site

    If you want to help out here, that's great, but when you post in old, already resolved threads doing that, that's not so good.

    Further any such changes should always be made in a child theme.

  6. Bibiano Wenceslao
    Posted 1 year ago #

    @WPyogi - I'm sorry about what I did mate. I'm heeding your advice and will avoid doing the same thing again.


  7. harman79
    Posted 1 year ago #

    @bibianowency - Thanks for the tip. It will certainly be used.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic