Wordpress - Highlight Nav


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <div id="mainnav">
  2. <ul id="mainnav">
  3.  
  4. <li<?php
  5. if (is_home())
  6. {
  7. echo " id=\"current\"";
  8. }?>>
  9. <a href="<?php bloginfo('url') ?>">Home</a>
  10. </li>
  11. <li<?php
  12. if (is_page('about'))
  13. {
  14. echo " id=\"current\"";
  15. }?>>
  16. <a href="<?php bloginfo('url') ?>/about">About</a>
  17. </li>
  18. <li<?php
  19. if (is_page('lessons'))
  20. {
  21. echo " id=\"current\"";
  22. }?>>
  23. <a href="<?php bloginfo('url') ?>/lessons">Lesson Pricing</a>
  24. </li>
  25. <li<?php
  26. if (is_page('student-gallery'))
  27. {
  28. echo " id=\"current\"";
  29. }?>>
  30. <a href="<?php bloginfo('url') ?>/student-gallery">Student Gallery</a>
  31. </li>
  32. <li<?php
  33. if (is_page('blog'))
  34. {
  35. echo " id=\"current\"";
  36. }?>>
  37. <a href="<?php bloginfo('url') ?>/blog">Blog</a>
  38. </li>
  39. <li<?php
  40. if (is_page('contact'))
  41. {
  42. echo " id=\"current\"";
  43. }?>>
  44. <a href="<?php bloginfo('url') ?>/contact">Contact</a>
  45. </li>
  46. </ul></div>

URL: http://wordpress.org/support/topic/how-to-menu-highlight-current-page

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.