WordPress.org

Support

Support » Themes and Templates » Need help regarding PHP code – “selected” for multiple pages.

Need help regarding PHP code – “selected” for multiple pages.

  • Hi there,

    On header.php one link’s coding is:

    <li<?php if (is_page()) echo ” class=\”selected\””; ?>>Speeches

    This is my problem. Currently all page links in the top navigation are “selected” because is_page(). If it’s is_page(298) then only the Speeches link will highlight when on the Speeches page.

    But, I want it to highlight on the speeches page as well as pages under the speeches page. How do I do this?

    I could do:

    <li<?php if (is_page(298)) echo ” class=\”selected\””; if (is_page(299)) echo ” class=\”selected\””; ?>>Speeches

    and continue like that, although there would be loads of “if (is_page(###)) echo ” class=\”selected\””;” – Is it possible to choose that it is “selected” when on certain pages?

    If so, how would I do this?

    Thanks 🙂

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Need help regarding PHP code – “selected” for multiple pages.’ is closed to new replies.
Skip to toolbar