<?php if (!is_page('x')) : get_sidebar(); endif; ?>

what do i need to do include page "y" and "z"?

7 answers

0
points
This was chosen as the best answer
<?php if (!is_page(array('x', 'y', 'z'))) : get_sidebar(); endif; ?>

Never mind. I got it. I should have written OR y OR z sorry if this confused some people.

Answered over 7 years ago by paleoindian
2
points

Switch statement:

 switch ($i) {
  case 0:
    echo "i equals 0";
    break;
  case 1:
    echo "i equals 1";
    break;
  case 2:
    echo "i equals 2";
    break;
 }

Or, if you need to use negatives:

 if (!is_page('x')) {
    get_sidebar();
} elseif (something_else) {
    get_somethingelse();
} elseif (a_third_thing) {
    get_a_third_thing();
}
Answered over 7 years ago by Shaun Robinson
1
point

Use double pipes (||) for "or" expressions.

From w3schools.

Answered over 7 years ago by Andrew Pennebaker
love 38
1
point

maybe we can use

<?php if (!is_page(x && y && z)) : get_sidebar(); endif; ?>

or

<?php if (!is_page(x || y || z)) : get_sidebar(); endif; ?>
Answered over 7 years ago by love
orta 244
0
points
<:?php include 'x.php'; ?> 

may indeed be all you need, there is also require ' y' the difference is that include will stop everything if it gets an error whilst require will continue.

Answered over 7 years ago by orta
Alex Holt 341
0
points

you can definitely use the array argument to the wordpress function.. but just so you understand how to do it in straight php... you would do:

<?php if (!is_page('x') && !is_page('y') && !is_page('z')): get_sidebar(); endif; ?>

This means, IF NOT page X AND IF NOT page Y AND IF NOT page Z - assuming you want it to get the sidebar if it's not on any of those pages.

So yeah, use && for logical AND and || for logical OR.

Answered over 7 years ago by Alex Holt
0
points

<?php if (!is_page(x || y || z)) : get_sidebar(); endif; ?> I think this is better.

Answered over 5 years ago by vysotsky