WordPress.org

Ready to get started?Download WordPress

Forums

If Else...include problem (1 post)

  1. Steven Jones
    Member
    Posted 6 years 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

Topic Closed

This topic has been closed to new replies.

About this Topic