Add sidebar to post view in Twenty Eleven theme
By default Twenty Eleven doesn’t display a sidebar on the post view page, but this can be added fairly easy. We have two options for it :
1- Doing it manual changes on the code.
For this open single.php and add near the bottom
<?php get_sidebar(); ?>
before
<?php get_footer(); ?>
and add the below code on the functions.php file for your theme
<?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);
}
2- Option is to use simply Twenty Eleven Theme Extensions plugin
This plugin is Easy to use customizations for the default theme Twenty Eleven
add sidebars back into your blog pages, and quickly change individual color settings.
Plugin link is here : http://wordpress.org/extend/plugins/twenty-eleven-theme-extensions/
Leave a Reply
Want to join the discussion?Feel free to contribute!