Title: single posts with sidebar
Last modified: December 4, 2025

---

# single posts with sidebar

 *  [Robert Poth](https://wordpress.org/support/users/rpweb777/)
 * (@rpweb777)
 * [6 months, 1 week ago](https://wordpress.org/support/topic/single-posts-with-sidebar/)
 * Once one could have single posts with sidebar in Twenty Eleven using the plugin“
   Twenty Eleven Theme Extensions”, but this plugin does not work anymore starting
   with PHP 8.
 * I found a workaround by making a change to the function.php of the parent theme–
   in function twentyeleven_body_classes( $classes ), second if statement [if ( 
   is_singular() …].
 * I would prefer to override this function in my child theme, but the function 
   twentyeleven_body_classes( $classes ) lacks the necessary “if ( function_exists…”
   statement.
 * I would appreciate if you could add this to a future update of Twenty Eleven.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [6 months, 1 week ago](https://wordpress.org/support/topic/single-posts-with-sidebar/#post-18742268)
 * The function you mentioned uses a WordPress hook. You can also use this to change
   the class specifications.
 * I’m not sure what exactly you want to achieve, but I assume you don’t want the“
   singular” class on the body if an additional condition is not met. In that case,
   I would recommend
 * a) removing the class using the hook.
 * b) then resetting it if your condition applies.
 * For example (untested):
 *     ```wp-block-code
       function twentyeleven_body_classes_replace_singular( $classes ) {    // find the entry with the class "singular".    $singular_key = array_search( 'singular', $classes, true );        // remove the entry.    if( $singular_key !== false ) {        unset( $classes[ $singular_key ] );    }        // now define your custom condition and add the class again.    // !!!        // return the resulting list of classes.    return $classes;}add_filter( 'body_class', 'twentyeleven_body_classes_replace_singular' );
       ```
   
 *  Thread Starter [Robert Poth](https://wordpress.org/support/users/rpweb777/)
 * (@rpweb777)
 * [6 months, 1 week ago](https://wordpress.org/support/topic/single-posts-with-sidebar/#post-18742838)
 * Thanks for your suggestion, I assume this should work in the child theme’s function.
   php; I will give it a try.
 * Problem and my workaround, which works but is overwritten with each update of
   the parent theme:
 * Twenty Eleven has a template single.php for displaying all single posts which
   doesn’t include the sidebar. With the function twentyeleven_body_classes( $classes),
   the div classes .singular are applied to single posts.
    1. Create a template single-sidebar.php for all single posts which includes the
       sidebar
    2. Add this template in the second if-statement of the function twentyeleven_body_classes(
       $classes ) to prevent the div classes .singular being applied to single posts.[&&!
       is_page_template ( ‘sidebar-single.php’ )]
 *  [plimfec](https://wordpress.org/support/users/plimfec/)
 * (@plimfec)
 * [6 months ago](https://wordpress.org/support/topic/single-posts-with-sidebar/#post-18753844)
 * I use the method below to add the sidebar to both pages and single posts in Twenty
   Eleven. No need for a plugin and thanks to the use of a child theme it remains
   intact after updating.
 * 1.
   Create a child theme containing functions.php, page.php, and single.php.
 * 2.
   Add this code to functions.php:
 *     ```wp-block-code
       // Twenty Eleven - Show sidebar on pages and single posts as well add_filter('body_class', 'fix_body_class_for_sidebar', 20, 2);function fix_body_class_for_sidebar($wp_classes, $extra_classes) {    if( is_single() || is_page() ){        if (in_array('singular',$wp_classes)){            foreach($wp_classes as $key => $value) {                if ($value == 'singular')                     unset($wp_classes[$key]);            }        }    }     return array_merge($wp_classes, (array) $extra_classes);}
       ```
   
 * 3.
   Add this call for the sidebar at the bottom of the files page.php and single.
   php (just above the call for the footer):
 *     ```wp-block-code
       <?php get_sidebar(); ?>
       ```
   
 * 4.
   Done.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘single posts with sidebar’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/twentyeleven/5.1/screenshot.png)
 * Twenty Eleven
 * [Support Threads](https://wordpress.org/support/theme/twentyeleven/)
 * [Active Topics](https://wordpress.org/support/theme/twentyeleven/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/twentyeleven/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/twentyeleven/reviews/)

## Tags

 * [pages](https://wordpress.org/support/topic-tag/pages/)
 * [sidebar](https://wordpress.org/support/topic-tag/sidebar/)
 * [single posts](https://wordpress.org/support/topic-tag/single-posts/)
 * [twenty eleven](https://wordpress.org/support/topic-tag/twenty-eleven/)

 * 4 replies
 * 3 participants
 * Last reply from: [plimfec](https://wordpress.org/support/users/plimfec/)
 * Last activity: [6 months ago](https://wordpress.org/support/topic/single-posts-with-sidebar/#post-18753844)
 * Status: not a support question