WordPress: Twentyeleven theme and Add Sidebars to Pages and Single Posts

Twentyeleven is a standard theme that comes with WordPress install (since V3.?). I like the layout, but customizing pages to include sidebar seems unfeasible. apparently it’s the theme’s feature for single posts and pages (as discussed in support group).

Remove singular class

Have a look at twentyeleven_body_classes() function in functions.php. it addes a ‘singular’ class to <body> tag which affects the layout. That needs to be removed.

If you’re using the theme directly, you can remove the function directly. However, the best way is to customize an existing theme by creating a child theme, so that any changes to the theme will not be lost if the theme is updated.

In child themes’s functions.php,

add_action('after_setup_theme', 'child_theme_setup');
function child_theme_setup() {
    // do your child theme setup.....

    // remove the body class
    remove_filter('body_class', 'twenty_eleven_body_class');

To keep the ‘singular’ feature of the theme

If you wish to keep the theme feature but want to have sidebar on other page templates, edit child theme’s functions.php (based on source):

add_fitler('body_class', 'child_theme_body_class', 20, 2);
function child_theme_body_class($classes, $extra) {
    if (is_page_template('new-page-template.php')) {
        foreach ($classes as $i => $c) {
             if ($c == 'singular') unset($classes[$i]);
    return array_merge($classes, (array) $extra);

Leave a Reply

Your email address will not be published. Required fields are marked *