WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Eleven
Removing Left Margin for Posts (4 posts)

  1. vost514
    Member
    Posted 1 year ago #

    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: https://twentyelevendemo.wordpress.com/2011/05/04/featured-posts-in-twenty-eleven/

    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:
    http://iamtgc.com/adding-the-sidebar-to-a-twentyeleven-child-theme/

    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 iamtgc.com 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!

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

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

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

    possible test the plugin http://wordpress.org/extend/plugins/twenty-eleven-theme-extensions/

  3. vost514
    Member
    Posted 1 year ago #

    Thanks for the quick response and suggestion alchymyth. I was only linking to WordPress.com 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

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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);
    }

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.