Twenty Eleven – New Page Template with Sidebar Correction

If you are creating a new page template for a child theme of Twenty Eleven, with a sidebar, you need to correct the body_class output to remove the css class .singular.

Add this to functions.php of your child theme:

add_filter('body_class', 'adjust_body_class', 20, 2);  
function 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 created more than one new page template with sidebar, change this one line in the code to something like:

if( is_page_template('new-sidebar-page-template-file-name.php') || is_page_template('another-sidebar-page-template.php') || is_page_template('further-sidebar-page-template.php') ) :

The above codes are similar to what I used in this recent article.