patrick patrick - 10 months ago 56
PHP Question

php multiple if statements?

This is going to seem like a noob question, sorry. I can't get my brain working this morning.

I am trying to perform multiple

statements, but they are not behaving properly. It appears to be always loading the least Template after it finds the one that it is looking for.
What is the best way to do something like this:

$post = $wp_query->post;
if ( in_category('7') ) {include(TEMPLATEPATH . '/post-experts.php');}
if ( in_category('6') ) {include(TEMPLATEPATH . '/post-radio.php');}
if ( in_category('5') ) {include(TEMPLATEPATH . '/post-lifestyle.php');}
else {include(TEMPLATEPATH . '/singleorigional.php');


Answer Source

You most likely want to do else if for the 2nd and 3nd ifs or have a way to know if none of the are true, do the else statement

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download