WordPress.org

Support

Support » How-To and Troubleshooting » is_page elseif multiple pages

is_page elseif multiple pages

  • Hey.
    I am trying to get multiple pages into is_page() with elseif without luck.

    I have this code in pages.php and have tried many different ways to get a sidebar to display at these pages. None of them have worked.

    <?php get_sidebar('dante'); ?>
    <?php elseif( is_page('214,216,218,220') ) : ?>

    Any help?

    My homepage.

Viewing 8 replies - 1 through 8 (of 8 total)
  • This is the hole code at the page.php

    <?php if( is_page('60') ) : ?>
    <?php get_sidebar('pages'); ?>
    <?php elseif( is_page('63') ) : ?>
    <?php get_sidebar('dogs'); ?>
    <?php elseif( is_page('65','101','110') ) : ?>
    <?php get_sidebar('dante'); ?>
    <?php elseif( is_page('214','216','218','220') ) : ?>
    <?php get_sidebar('dantea'); ?>
    <?php elseif( is_page('74') ) : ?>
    <?php get_sidebar('goldie'); ?>
    <?php else : ?>
    <?php get_sidebar(); ?>

    You should be using an array 🙂

    <?php
    if ( is_page( array(1, 2, 3, 4, 5) ) )
    {
        // do something
    }
    elseif ( is_page( array(6, 7, 8, 9, 0) ) )
    {
        // do something
    }
    ?>

    I can´t get it to function with that 🙁

    Moderator Michael

    @alchymyth

    Forum Moderator

    replace any of those lines:

    is_page('65','101','110')

    with the right syntax:

    is_page(array('65','101','110'))

    alchymyth, if I use that one, the next message comes.

    Parse error: syntax error, unexpected ‘:’ in /customers/5/b/d/bluechalo.com/httpd.www/wp-content/themes/titan_child/page.php on line 18

    Hiranthi Molhoek-Herlaar, sorry.. don´t get it!

    Moderator Michael

    @alchymyth

    Forum Moderator

    if I use that one, the next message comes.

    Parse error: syntax error, unexpected ‘:’

    watch for the exact number of brackets used – opening and closing brackets need to match.

    i.e. look again exactly at what I suggested to replace.

    thanx a lot! got it now.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘is_page elseif multiple pages’ is closed to new replies.