• Hi. I’m not too well-schooled in PHP “if” statements, and I’m brand new to administrating WordPress. I’m having a problem with my conditional navigation highlighting.

    I’m calling my navigation menu from one file (header.php), and I’m trying to achieve conditional highlighting. Here’s my code as it stands:

    <div id="nav">
    		<ul id="navbar">
    		<li <?php if (is_home()) {?>class="current_page_item"<?php } ?>><a href="<?php echo get_settings('home'); ?>/">Home</a></li>
            <li><a href="http://forum.communitycarefund.org" target="_blank">Forum</a></li>
    		<li <?php if (is_page(3)) {?>class="current_page_item"<?php } ?>><a href="<?php echo get_settings(3); ?>/">About</a></li>
    		<li <?php if (is_page(4)) {?>class="current_page_item"<?php } ?>><a href="<?php echo get_settings(4); ?>/">Events</a></li>
            <li <?php if (is_page(5)) {?>class="current_page_item"<?php } ?>><a href="<?php echo get_settings(5); ?>/">Donate</a></li>
            <li <?php if (is_page(6)) {?>class="current_page_item"<?php } ?>><a href="<?php echo get_settings(6); ?>/">Resources</a></li>
            <li <?php if (is_page(12)) {?>class="current_page_item"<?php } ?>><a href="<?php echo get_settings(12); ?>/">In Action</a></li>
    		</ul></div>

    What ends up happening is the links all end up pointing to the index.php file rather than the page_id indicated in each link. I know there’s probably something small going wrong here, but I can’t figure out what it is.

    Here’s the site in question so you can see what I’m talking about:

    http://www.communitycarefund.org/blog/

    Any/all help is appreciated.

Viewing 1 replies (of 1 total)
  • Thread Starter mattchandl3r

    (@mattchandl3r)

    Strike that. Figured it out. Just needed a smoke break, ya dig?

    For the curious:

    <div id="nav">
    		<ul id="navbar">
    		<li <?php if (is_home()) {?>class="current_page_item"<?php } ?>><a href="<?php echo get_settings('home'); ?>/">Home</a></li>
            <li><a href="http://forum.communitycarefund.org" target="_blank">Forum</a></li>
           	<li <?php if (is_page('About')) {?>class="current_page_item"<?php } ?>><a href="?page_id=3">About</a></li>
            <li <?php if (is_page('Events')) {?>class="current_page_item"<?php } ?>><a href="?page_id=4">Events</a></li>
            <li <?php if (is_page('Donate')) {?>class="current_page_item"<?php } ?>><a href="?page_id=5">Donate</a></li>
            <li <?php if (is_page('Resources')) {?>class="current_page_item"<?php } ?>><a href="?page_id=6">Resources</a></li>
            <li <?php if (is_page('In Action')) {?>class="current_page_item"<?php } ?>><a href="?page_id=12">In Action</a></li>
    		</ul></div>
Viewing 1 replies (of 1 total)
  • The topic ‘Conditional Navigation Highlighting Problems’ is closed to new replies.