WordPress.org

Support

Support » Themes and Templates » How to set the active tab in nav for a page

How to set the active tab in nav for a page

  • Hi Guys,

    I’ve a wordpress site with 5 tabs in nav, corresponding to 5 pages. Now for some other pages, I would also like certain tab to be displayed as active for the page. How can I achieve this?

    For example, now going to home.php will have the “Home” tab active. But I also have another, say, newhome.php, in which I would also like the “Home” tab to appear as active. How to do that?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Emil Uzelac
    Theme Review Admin

    @emiluzelac

    It always helps to provide us with your site, however here’s the example how you can do this:

    Assuming that your main menu is styled with .menu from your stylesheet.

    .menu .current_page_item a {
        color: #777;
    }

    This CSS style will change the color of your current/active page to #777 (grey) . You can add background as well.

    Here is my site:
    http://insidegig.com/blog/
    In this page, the tab is highlighted as expected.
    But in this one:
    http://insidegig.com/uncategorized/make-your-office-work-for-you/

    No tab is highlighted. I’m wondering how to designate which tab to highlight for the second page?

    Emil Uzelac
    Theme Review Admin

    @emiluzelac

    Not sure what needs to be highlighted here? Make your office work for you is a post from “uncategorized” category.

    You are here: Home / For Employers / Make Your Office Work for You

    The last part tells you where you are via breadcrumb.

    Is there anyway to get the “Training” tab as current for the second page?

    Emil Uzelac
    Theme Review Admin

    @emiluzelac

    Yes, so if all posts are under the same category and/or you want “Training
    ” to remain current, try this in your header.php or where your main menu is located.

    <li class="<?php if ( is_home() || is_category() ) { echo "current_page_item"; } ?>"><a href="<?php echo get_option ('home'); ?>">Training</a></li>

    Thanks a lot. I’ll try that.

    Emil Uzelac
    Theme Review Admin

    @emiluzelac

    No problem 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to set the active tab in nav for a page’ is closed to new replies.