Forums
Home / Fixing WordPress / If Else…include problem
(@rainemaida)
15 years, 10 months ago
Hi,
On single.php I am trying to include a sidebar which displays differently depending on which category the post is in. Here is my PHP.
<?php $post = $wp_query->post; if ( in_category('1') ) { include (TEMPLATEPATH . '/blogsidebar.php'); } elseif ( in_category('3') ) { include (TEMPLATEPATH . '/portfoliosidebar.php'); } elseif ( in_category('4') ) { include (TEMPLATEPATH . '/newssidebar.php'); } else { include (TEMPLATEPATH . '/sidebar.php'); } ?>
If I remove this code altogether the page works, however when I add it, the page does not work.
Please advise.
Cheers, Steve