Problem with active in links in dynamic WordPress nav menu.
-
I am working on this site: https://www.semblance.co.za/bronzeage/
All the pages are created as WordPress pages or template pages.
‘projects’ in the menu is the WordPress blog.I have used the following code for the dynamic nav menu with the slug and links changed accordingly.
<?php if(is_page('contact')) { ?> <li class="page_item current_page_item"><a href="/contact/">contact</a></li> <?php } else { ?> <li class="page_item"><a href="/contact/">contact</a></li> <?php } ?>
It works fine for all the pages, except the ‘home page’ nav stay active with the page nav of the page that is being viewed.
I found the following code to use with the ‘projects’ (blog) page:
<?php if(is_home() && !is_paged()){ ?> <li class="current_page_item"> <a href="<?php echo get_settings('latest-projects'); ?>" >projects</a> </li> <?php } else { ?> <li> <a href="<?php echo get_settings('latest-projects'); ?>" >projects</a> </li> <?php } ?>
It links through to the static ‘home page’.
Do anyone have some thoughts, ideas or solution/s for me?
Thank you in advance.
- The topic ‘Problem with active in links in dynamic WordPress nav menu.’ is closed to new replies.