Support » Theme: Twenty Eleven » Removing Left Margin for Posts

  • I use the twenty eleven theme for several WordPress sites. Here is a link to a demo of the theme. On this page of the demo, it explains:

    Twenty Eleven leaves sidebars off of posts and pages to highlight your content and proudly feature the magic that happens between your writing and your visitorโ€™s comments. That said, sometimes you just want a sidebar on your pages. Selecting the custom Sidebar Template for your page will do just that. ๐Ÿ™‚

    However, while this works well for PAGES, there does not appear to be any such option for POSTS. All POSTS look sort of like this:

    In other words, the content is basically centered with a large left-hand margin. So that is my question: How can I get rid of that big left-hand margin on POSTS? There’s got to be a simple way to do it with CSS without affecting PAGES, right?

    I am trying to make all POSTS look just like PAGES WITH SIDEBARS as seen at the link above (this one). (Note: The difference is that I have the sidebar on the right, not the left as shown on the demo linked above)

    I tried this method:

    Adding <?php get_sidebar(); ?> to the single.php file in my child theme does indeed add the sidebar. However, because the actual content of the post has the large left margin, it pushes the sidebar down beneath the actual post. I modified functions.php as outlined at that link above, and that did make POSTS display correctly (sidebar next to the content); however, it also messed up all PAGES with no sidebars. Instead of taking up the full width of the content area as normal, they began to only take up 2/3rds just like a POST, with the other 1/3 taken up by the side bar.

    Yes, I am using child themes! ๐Ÿ™‚

    Any help would be GREATLY appreciated! Thanks in advance!

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


    Forum Moderator

    you are quoting a lot of resources which have not much value when you are dealing with ..

    please use the forum search to check for solutions to include a sidebar into single posts in Twenty Eleven.

    possible test the plugin

    Thanks for the quick response and suggestion alchymyth. I was only linking to because a demo of the Twenty Eleven theme is hosted there; I wanted people to be able to see what I meant about posts having a large left-hand margin.

    I will definitely try that plug-in if I can’t find any other solution, but I would think there’s be a simple way to remove the left-hand margin of POSTS with CSS without affecting PAGES, no? And perhaps tweak the width of the content area a little? I would think it’d only be a few lines added to my child theme’s style.css



    Forum Moderator

    there’s be a simple way to remove the left-hand margin of POSTS with CSS without affecting PAGES, no?

    you would add the <?php get_sidebar(); ?> in single.php just before the ‘get_footer()’ line;
    then add a filter to functions.php of the child theme, to remove the .singular body_class;

    example (simplified, based on my tutorial):

    add_filter('body_class', 'adjust_single_post_body_class', 20, 2);
    function adjust_single_post_body_class($wp_classes, $extra_classes) {
    if( is_single() ) :
          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);
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Removing Left Margin for Posts’ is closed to new replies.