Title: Custom sidebar template problem
Last modified: August 21, 2016

---

# Custom sidebar template problem

 *  [carnelian](https://wordpress.org/support/users/carnelian/)
 * (@carnelian)
 * [13 years ago](https://wordpress.org/support/topic/custom-sidebar-template-problem/)
 * I’m using different sidebars on different pages by adding the sidebar content
   to a PHP include file which I use as a template.
 * Now there’s a silly little problem I can’t figure out how to solve. The sidebar
   pushes the rest of the content down even if it’s not too wide.
 * Here you can see the problem: [http://www.1.whirlwind.nu/?page_id=93](http://www.1.whirlwind.nu/?page_id=93)

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years ago](https://wordpress.org/support/topic/custom-sidebar-template-problem/#post-3770975)
 * the linked page uses the ‘sidebar template’ and displays fine (at least for me
   in FF20)
 * do you have any pages with the sidebar problem evident?
 * what is the full code of those _‘PHP include file which I use as a template’_?
 * Twenty Eleven uses the `body_class()` `.singular` to control the layout with 
   or without sidebars (done in functinos.php of the theme); you will probably need
   to adjust that together with your included php;
 * be aware that any customisations will get lost when you update the theme; consider
   to create and use a child theme for customisations – [http://codex.wordpress.org/Child_Themes](http://codex.wordpress.org/Child_Themes)
 *  Thread Starter [carnelian](https://wordpress.org/support/users/carnelian/)
 * (@carnelian)
 * [13 years ago](https://wordpress.org/support/topic/custom-sidebar-template-problem/#post-3770979)
 * You don’t see that the content is pushed down? It looks like that when I use 
   Firefox and Opera. Haven’t checked in other browsers.
 * I always download WP themes so there’s always a backup on my computer in case
   I screw up the theme.
 * Here’s the template:
 *     ```
       <?php
       /**
        * Template Name: Sidebar1
        * Description: A Page Template that adds a sidebar to pages
        *
        * @package WordPress
        * @subpackage Twenty_Eleven
        * @since Twenty Eleven 1.0
        */
   
       get_header(); ?>
   
       		<div id="primary">
   
       			<div id="content" role="main">
   
       				<?php while ( have_posts() ) : the_post(); ?>
   
       					<?php get_template_part( 'content', 'page' ); ?>
   
       					<?php comments_template( '', true ); ?>
   
       				<?php endwhile; // end of the loop. ?>
   
       			</div><!-- #content -->
   
       		</div><!-- #primary -->
   
       <?php get_footer(); ?>
       <?php include ('sidebar1.php'); ?>
       ```
   
 * And the PHP include file: <div id=”secondary”>
    <h1>Biografi</h1> <h1>Historik
   </h1> <h1>Diskografi</h1> </div> <!– end #sidebar1 –>`
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years ago](https://wordpress.org/support/topic/custom-sidebar-template-problem/#post-3770988)
 * the body_class output of your linked page indicates to me that the page is using
   a page template with the file name _**sidebar-page.php **_(which is one of the
   default templates of Twenty Eleven):
 * `<body class="page page-id-93 page-template page-template-sidebar-page-php single-
   author two-column right-sidebar">`
 * under which file name have you save the posted page template ‘Sidebar1’ ?
 * I now see the problem with the pushed-down content column;
 * this might be caused by the fact that the linked page’s html output in the browser
   does not match the structure of your posted template code; for instance, the ‘
   sidebar’ appears before the content…
 * the browser also shows some attempted code in teh content of the page:
 *     ```
       ...
       <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
       <p><?php get_sidebar('sidebar1'); ?></p>
       ```
   
 * btw: the sidebar should be called before the footer.
 * possibly review [http://codex.wordpress.org/Function_Reference/get_sidebar](http://codex.wordpress.org/Function_Reference/get_sidebar)
 *  Thread Starter [carnelian](https://wordpress.org/support/users/carnelian/)
 * (@carnelian)
 * [13 years ago](https://wordpress.org/support/topic/custom-sidebar-template-problem/#post-3770990)
 * I removed that sidebar code in the entry text. Not sure how it got there.
    I 
   also moved the sidebar code above the footer code. Still looking the same though.
 * The Sidebar1 template is just called sidebar1
 *  Thread Starter [carnelian](https://wordpress.org/support/users/carnelian/)
 * (@carnelian)
 * [13 years ago](https://wordpress.org/support/topic/custom-sidebar-template-problem/#post-3770993)
 * Ok it’s working now. This is why I shouldn’t code when I’m tired. Like you pointed
   out, I used the wrong template. Before my own wasn’t visible in the list so I
   must have clicked the wrong one. Now it’s visible and working.
 * Thank you for the help. It’s much appreciated.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years ago](https://wordpress.org/support/topic/custom-sidebar-template-problem/#post-3770995)
 * check the code in sidebar-page.php
 * also check which page template is attributed to the page with the ID 93 (‘BIO’?)
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years ago](https://wordpress.org/support/topic/custom-sidebar-template-problem/#post-3770997)
 * well done 😉
 * > Ok it’s working now.
 * that is because you probably have attributed the right template to that page;
 * this is the body tag now:
    `<body class="page page-id-93 page-template page-template-
   sidebar1temp-php single-author singular two-column right-sidebar">`
 * I can tell it is now using the template file _**sidebar1temp.php**_

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

The topic ‘Custom sidebar template problem’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/custom-sidebar-template-problem/#post-3770997)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
