Forums

dynamic link highlight for main Nav AND sidebar sub-Nav? (1 post)

  1. veebis
    Member
    Posted 1 year ago #

    I have a global text nav setup with dynamic current-page highlighting working great.

    Here is my code, in header.php:

    <?php
    if ( is_page('Page One') ) { $current_page_item = 'pageone'; }
    elseif ( is_page('Page Two') ) { $current_page_item = 'pagetwo'; }
    ?>
    
    <style type="text/css">
    span.<?php echo $current_page_item; ?> {
    color:#000;
    font-weight:bold;
    }
    </style>

    Then, in the main nav (in header.php):

    <li><a href="#"><span class="pageone">Page One</span></a></li>
    <li><a href="#"><span class="pagetwo">Page Two</span></a></li>

    and so on, and it's all working great.

    What I would like to do, though, is also have links in certain page-specific sub-nav sidebars (sidebar-one.php, etc.) function in the same way (highlighting the current page link).

    But if I create a second php call in the header (using different class names), one seems to cancel the other out (only one functions). I tried inserting <?php wp_reset_query(); ?> into the pages before the sidebar call, but it didn't help.

    Any tips?

Topic Closed

This topic has been closed to new replies.

About this Topic