Basically what I’m trying to accomplish is display a generic sidebar for all other pages…i.e. search archives, tags, cats etc.
See some working examples how the
if
elseif
else
are combined: Conditional_Tags#Working_Examples
Thanks that helped… I got it working. I had my PHP all wrong. Here is what I ended up with.
<?php
if (is_home()) { include (TEMPLATEPATH . '/regularsidebar.php'); }
elseif (is_category()) { include (TEMPLATEPATH . '/regularsidebarsidebar.php'); }
elseif (is_single()) { include (TEMPLATEPATH . '/regularsidebarsidebar.php'); }
elseif (is_page()) {
if (is_page('homepage')) { include (TEMPLATEPATH . '/homesidebar.php'); }
elseif (is_page('contact')) { include (TEMPLATEPATH . '/contactsidebar.php'); }
else { include (TEMPLATEPATH . '/regularsidebar.php'); }
}
else { include (TEMPLATEPATH . '/regularsidebar.php'); }
?>
Glad you got it working.
(maybe you don’t need the last “else” line twice…)
i am having a similar problem:
My conditional statement works for all cases except arts-entertainment page. Below is my code, any help would be appreciated.
===================
<?php
if ( in_category(‘news’) || post_is_in_descendant_category( 13 ) ) {
include ‘includes/nav-home.php’;
}
elseif ( in_category(‘business’) || post_is_in_descendant_category( 14 ) || is_page(‘business’)) {
include ‘includes/nav-bus.php’;
}
elseif ( in_category(‘arts-entertainment’) || post_is_in_descendant_category( 17 ) || is_page(‘arts-entertainment’)) {
include ‘includes/nav-ent.php’;
}
elseif ( in_category(‘living’) || post_is_in_descendant_category( 19 ) || is_page(‘living’)) {
include ‘includes/nav-liv.php’;
}
elseif ( in_category(‘opinion’) || post_is_in_descendant_category( 18 ) || is_page(‘opinion’)) {
include ‘includes/nav-opn.php’;
}
elseif ( in_category(‘sports’) || post_is_in_descendant_category( 20 ) || is_page(‘sports’)) {
include ‘includes/nav-spt.php’;
}
else {
include ‘includes/nav-home.php’;
}
?>
==================
FYI: The idea is to use a different color for navigation for each page in the conditional statement.