250-357-9267 [email protected]

If you’ve been using the newest TwentyEleven theme with WordPress you may have noticed that when folks click on one of your blog posts the resulting page no longer includes the sidebar.  Not really sure why, but if you want it back here is a fix.

FYI you’ll need some coding savvy to do this one, and you should already have a child theme set up.  If you haven’t set up your child theme yet, read this post to learn how to create your own child theme.

Now here are the rest of the instructions:

1. Open your child theme version of Single.php in your editor of choice and near the bottom of the page add this (add it right above the line that says <?php get_footer(); ?> ):

<?php get_sidebar(); ?>

2. If you haven’t already, create a functions.php file for your theme and add this to it:

<?php
add_filter(‘body_class’, ‘blacklist_body_class’, 20, 2);
function blacklist_body_class($wp_classes, $extra_classes) {
if( is_single() || is_page() ) :
// List of the classes to remove from the WP generated classes
$blacklist = array(‘singular’);
// Filter the body classes
foreach( $blacklist as $val ) {
if (!in_array($val, $wp_classes)) : continue;
else:
foreach($wp_classes as $key => $value) {
if ($value == $val) unset($wp_classes[$key]);
}
endif;
}
endif;   // Add the extra classes back untouched
return array_merge($wp_classes, (array) $extra_classes);
}

3. Add a few css adjustments to your style.css file:

.nav-previous {
float: left !important;
}
#respond {
margin: 0 auto 1.625em;
padding: 1.625em;
position: relative;
width: 88.9%;
}
.commentlist {
width: 78.9%;
}
/* adjust author bio */
.singular #author-info {
margin: 2.2em 0 0;
padding: 20px 5.4%;
width: 550px;
}

Voila!  Now your site should display a sidebar properly on individual post pages.  Yay!