Conditional Navigation Highlighting Problems
-
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="https://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:
https://www.communitycarefund.org/blog/
Any/all help is appreciated.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Conditional Navigation Highlighting Problems’ is closed to new replies.