views:

31

answers:

2

I'm trying a simple multiple conditional statement which should work fine with PHP but WordPress says no. What am I missing?

<?php if (is_page('sample1') || is_page('sample2') || is_page('sample3') ||     is_page('sample4')) { ?>
include this
<?php } else { ?>
include this instead
<?php } ?>
+2  A: 

Undefined function?

How are you calling footer.php from your theme?

Adam
@Adam's right - `footer.php` should be loaded by, and within, WordPress - sounds like you're trying to load it yourself, either outside WP, or before the function `is_page()` is available.
TheDeadMedic
I was including the footer in a regular template. Think I solved the matter now, see below.
Staffan Estberg
A: 

It has nothing to do with the code you posted. It has everything to do with the path to the footer or where you are trying to load it within the page lifecycle. Also check if the path is right.

The Mirage
I noticed now that I put a <? } ?> as closing tag instead of <?php } ?> for the whole statement and it's content. It works now. Shouldn't it have worked either way? I guess mixing <?php with <? can cause such problems.
Staffan Estberg
Which tag you use should make no difference. I have used both many times. As long as they match, which one doesn't matter...unless you have your server config different or something odd is going on with the interpreter.
The Mirage