WordPress.org

Ready to get started?Download WordPress

Forums

is_page + elseif + multiple pages (9 posts)

  1. doggyus
    Member
    Posted 2 years ago #

    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.

  2. doggyus
    Member
    Posted 2 years ago #

    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(); ?>
  3. Hiranthi
    Member
    Posted 2 years ago #

    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
    }
    ?>
  4. doggyus
    Member
    Posted 2 years ago #

    I can´t get it to function with that :(

  5. replace any of those lines:

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

    with the right syntax:

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

  6. doggyus
    Member
    Posted 2 years ago #

    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

  7. doggyus
    Member
    Posted 2 years ago #

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

  8. 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.

  9. doggyus
    Member
    Posted 2 years ago #

    thanx a lot! got it now.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.