[resolved] function is_page - state always on -help? (3 posts)

  1. matthisco
    Posted 3 years ago #

    I'm trying to use a basic statment in my menu to change the selected state of my menu. The last 'if' statement works fine, the others are always 'on' can anyone please tell me why?

    <?php if ( is_page(our-mission)){echo "nav-active";} ?>
    <?php if ( is_page(vision-values)){echo "nav-active";} ?>"
    <?php if ( is_page(our-board)){echo "nav-active";} ?>"
    <?php if ( is_page(latest-news)){echo "nav-active";}  ?>"
    <?php if ( is_page('have-your-say')){echo "nav-active";}  ?>"
    <?php if ( is_page(contact)){echo "nav-active";}  ?>">

    I've used similar code on other sites and it works fine. Could my browser be caching the page state that keeps echoing the nav-active?

    Many thanks

  2. Michael
    Forum Moderator
    Posted 3 years ago #

    try to use quotes around each of the page slugs;


    <?php if ( is_page('our-mission')){echo "nav-active";} ?>
  3. matthisco
    Posted 3 years ago #

    Ah great! thanks very much

Topic Closed

This topic has been closed to new replies.

About this Topic