WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. matthisco
    Member
    Posted 1 year 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. alchymyth
    Forum Moderator
    Posted 1 year ago #

    try to use quotes around each of the page slugs;

    example:

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

    Ah great! thanks very much

Topic Closed

This topic has been closed to new replies.

About this Topic