WordPress.org

Support

Support » How-To and Troubleshooting » Highlight parent page in nav when on child page

Highlight parent page in nav when on child page

Viewing 4 replies - 1 through 4 (of 4 total)
  • Ignore the code snippet, it converted to html. Let me try this:

    <ul id="nav">
    		<li><a <?php if (is_home()) echo('class="current" '); ?>href="<?php bloginfo('url'); ?>">home</a></li>
    		<li><a <?php if (is_archive() || is_page('archives')) echo('class="current" '); ?>href="<?php bloginfo('url'); ?>/archives/">archives</a></li>
    		<li><a <?php if (is_page('about-us')) echo('class="current" '); ?>href="<?php bloginfo('url'); ?>/about-us/">about us</a></li>

    Is there a reason you’re manually listing the top-level pages?

    Take a look at the Codex entry for wp_list_pages. It explains the use of that template tag in pretty good detail; wp_list_pages gives active pages a class of current_page_item, and active pages’ parents a class of current_page_parent. Styling is just a matter of changing “current” in your stylesheet to “current_page_item” or “current_page_parent”, if you let WP do the dirty work.

    I’m manually listing them so I can control the order in which they appear.

    I had the same issue (now fixed) – try this: http://www.umaitech.com/cms/?p=27#comment-5489

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Highlight parent page in nav when on child page’ is closed to new replies.
Skip to toolbar