Title: Using Multiple Side Bars with an if/else statement
Last modified: August 18, 2016

---

# Using Multiple Side Bars with an if/else statement

 *  Resolved [fibnok](https://wordpress.org/support/users/fibnok/)
 * (@fibnok)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/using-multiple-side-bars-with-an-ifelse-statement/)
 * I need to set up my blog to use different sidebars based on post number. I modified
   my “single.php” file with the following code:
 * <?php
    if (is_single(’30’)) get_sidebar30(); else get_sidebar(); ?>
 * I expected this to get “sidebar30” if post30=true, otherwise it would grab the
   standard sidebar. Well, the “else” part of the statement works, but the “if (
   is_single(’30’)) get_sidebar30();” returns a blank sidebar.
 * The only difference between sidebar.php and sidebar30.php is an iframe element
   grabbing an amazon product. But when I load post 30, the sidebar is completely
   blank.
 * Any ideas?
 * I’m using the theme “fluid-blue-10” with widgets enabled. Not sure if that makes
   a difference.
 * thanks,
 * Datamonkey

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/using-multiple-side-bars-with-an-ifelse-statement/#post-637814)
 * `get_sidebar30();`
 * That will never work since get_sidebar30 is NOT a function defined in the WP 
   core files (as opposed to get_sidebar, which IS a function written in the core
   files).
 * To include other template files that reside in your theme folder, use this:
    `
   <?php include (TEMPLATEPATH . '/yourfile.php'); ?>`
 * Use it as it is, just replace the filename!
 *  Thread Starter [fibnok](https://wordpress.org/support/users/fibnok/)
 * (@fibnok)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/using-multiple-side-bars-with-an-ifelse-statement/#post-637835)
 * Hey Moshu,
 * Thanks for the feedback, but I can’t get it to work. Here is the code I’m using:
 * <?php
    if (is_single(’30’)) <?php include (TEMPLATEPATH . ‘/sidebar30.php’); ?
   > else get_sidebar(); ?>
 * The sidebar still shows up completly blank. Just to make sure I hadn’t messed
   up the file “sidebar30.php” I modified the code to include “sidebar.php”, the
   standard sidebar. Can you see any errors in the code?
 * thanks,
 * Datamonkey
 *  Thread Starter [fibnok](https://wordpress.org/support/users/fibnok/)
 * (@fibnok)
 * [18 years, 6 months ago](https://wordpress.org/support/topic/using-multiple-side-bars-with-an-ifelse-statement/#post-637881)
 * Never mind. Got it. Here is the code that works.
 * <?php
    if (is_single(’30’)) include (TEMPLATEPATH . ‘/sidebar30.php’); else get_sidebar();?
   >
 * Thanks for your help, Moshu.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Using Multiple Side Bars with an if/else statement’ is closed to new 
replies.

 * 3 replies
 * 2 participants
 * Last reply from: [fibnok](https://wordpress.org/support/users/fibnok/)
 * Last activity: [18 years, 6 months ago](https://wordpress.org/support/topic/using-multiple-side-bars-with-an-ifelse-statement/#post-637881)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
