0

I am trying to extend the twentyeleven theme's sidebar template. My custom template (its incomplete) is as follows:

<?php
/**
 * Template Name: Quote Request
 * Description: A Page Template that is a free quote request form
 *
 * @package WordPress
 * @subpackage Twenty_Eleven (Custom)
 * @since Twenty Eleven 1.c
 */ 
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_sidebar(); ?>
<?php get_footer(); ?>

I just name a copy of sidebar-page.php which I belive is used for creating Sidebar template pages. But I don't get the intended results. Here is what I get:

My template result

But when I select the sidebar template from the editor, I get:

Sidebar template

I am trying to acheive this before I add my custom page elements. Can somebody point me to correct direction? I am just starting on wordpress.

2
  • What are you trying to do? I don't get it?
    – kaiser
    Commented Feb 28, 2012 at 12:41
  • I assume the issue is the page content width not changing on your custom page template, thereby causing your sidebar to be pushed beneath the page content? Commented Feb 28, 2012 at 13:15

1 Answer 1

1

you need to correct the automatically added body_class .singular to get the layout;

for instance use this in functions.php of your child theme (which you should have created to work from):

add_filter('body_class', 'pagetemplate_adjust_body_class', 20, 2);
function pagetemplate_adjust_body_class($wp_classes, $extra_classes) { 

if( is_page_template('new-sidebar-page-template-file-name.php') ) :
// Filter the body classes     

      foreach($wp_classes as $key => $value) {
      if ($value == 'singular') unset($wp_classes[$key]);
      }

endif;
// Add the extra classes back untouched
return array_merge($wp_classes, (array) $extra_classes );
}

if you are working with a clone of Twenty Eleven, see near the end of functions.php and expand this line with your page tempalte:

if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
1
  • Mihael, thanks for the answer. +1 for introducing the child theme concept to me. :) Commented Feb 28, 2012 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.