Title: Calling different sidebars code
Last modified: August 18, 2016

---

# Calling different sidebars code

 *  [jonthegeologistgmailcom](https://wordpress.org/support/users/jonthegeologistgmailcom/)
 * (@jonthegeologistgmailcom)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/calling-different-sidebars-code/)
 * Hi
 * I know this topic has been raised before but having searched through, I’m still
   struggling.
 * I’ve created 2 new sidebar configurations (called sidebarblog and sidebarindex)
   which, you may guess, display different sidebars depending on it being a blog
   page or a mainpage
 * I’ve tested the code within each and know it to work.
 * The sidebar.php now contains the following :
 * <?php if (is_home()) {
    get_sidebarblog(); } else { get_sidebarindex(); } ?>
 * I get an error that I don’t understand : Fatal error: Unknown function: get_sidebarindex()
   in …sidebar.php on line 4
 * The url is [http://imjon.com](http://imjon.com)
 * That suggests to me that the files it’s looking for don’t exist, but they do.
   I’m sure there’s something very simple I’m doing wrong here, but I can’t see 
   it. If you can help, I’d be grateful.
 * Jonathan

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

 *  [Samuel B](https://wordpress.org/support/users/samboll/)
 * (@samboll)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/calling-different-sidebars-code/#post-546292)
 * Wouldn’t you still need to define it from the theme’s page.php or single.php (
   or wherever you’re wanting it) – something like:
    `<?php include (TEMPLATEPATH."/
   sidebarindex.php"); ?>`
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 1 month ago](https://wordpress.org/support/topic/calling-different-sidebars-code/#post-546298)
 * The “get_sidebar()” is a function, not a file. It’s a convenience built into 
   WordPress for a number of reasons.
 * However, you can’t just make them up on the fly like that. If you do, then you
   need to use code like samboll gave above to include the files directly.
 *  Thread Starter [jonthegeologistgmailcom](https://wordpress.org/support/users/jonthegeologistgmailcom/)
 * (@jonthegeologistgmailcom)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/calling-different-sidebars-code/#post-546378)
 * solved the problem using (for sidebar.php)
 * <?php if (is_home()) {
    include (TEMPLATEPATH . “/sidebarblog.php”);
 *  } else {
    include (TEMPLATEPATH . “/sidebarother.php”); } ?>
 * The code for each of the other sidebars are variations on the original… thanks
   for your help. Hope this code helps others.

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

The topic ‘Calling different sidebars code’ is closed to new replies.

## Tags

 * [different](https://wordpress.org/support/topic-tag/different/)
 * [pages](https://wordpress.org/support/topic-tag/pages/)

 * 3 replies
 * 3 participants
 * Last reply from: [jonthegeologistgmailcom](https://wordpress.org/support/users/jonthegeologistgmailcom/)
 * Last activity: [19 years, 1 month ago](https://wordpress.org/support/topic/calling-different-sidebars-code/#post-546378)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
