Forums

[resolved] Checking for multiple pages with is_page()? (4 posts)

  1. CMoseley
    Member
    Posted 3 years ago #

    Is there a way to check for multiple pages with is_page()?

    I want to make a menu highlight when say someone is on page 3 and 5 and thus I would go:

    <?php
    if (is_page(3 || 5))
    {
    echo ('class="red"')
    }
    ?>

    But that always returns true no matter what page I am on. Is there any way to check for multiple pages without writing an individual if statement for each page?`

  2. Kafkaesqui
    Moderator
    Posted 3 years ago #

    The is_page() conditional can only test on one Page at a time, so you want to do:

    if ( is_page(3) || is_page(5) )

  3. syncbox
    Member
    Posted 2 years ago #

    So, if you want to check for 3 or more, you write it

    if (is_page(3) || is_page(5) || is_page(7))

    ??

  4. syncbox
    Member
    Posted 2 years ago #

    cool! thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic