WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] Twenty Eleven Child Theme Single Post Page with Sidebar (20 posts)

  1. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Setting up a site with latest Twenty Eleven Child Theme and note that there is no longer a Single Post Page with Sidebar option. I have read through much here today on this to no avail. I already tried adding the get sidebar function to single.php which worked but was a mess CSS-wise...please provide a tip on how to go about having both posts and pages use the same sidebar/widget setup...I want the left sidebar present on all menu clicks. http://www.gfld82.com/test-post/

  2. please provide a tip on how to go about having both posts and pages use the same sidebar/widget setup

    Try a forum search? :
    http://wordpress.org/search/Twenty+Eleven+Child+Theme+Single+Post+Page+Sidebar?forums=1

  3. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    I tried all kinds of searches! They all point to PAGE instead of POST when sidebar is added to the search. Can you point to one that is clear on this?

  4. alchymyth
    Forum Moderator
    Posted 2 years ago #

    that there is no longer a Single Post Page with Sidebar option.

    there never was one.

    try a plugin http://wordpress.org/extend/plugins/twenty-eleven-theme-extensions/

    how to go about having both posts and pages use the same sidebar/widget setup

    or read my article http://www.transformationpowertools.com/wordpress/twenty-eleven-sidebar-on-single-posts-and-pages

  5. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    I saw that link plus many more offering various solutions...now that I see that one is from you - I shall use it...thanks

  6. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Did not work I got this error:

    Parse error: syntax error, unexpected $end in xxxxxxx/wp-content/themes/twentyeleven-child/functions.php on line 73

    Any thoughts?

  7. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    The code does not copy over properly...extra spaces, tabs, and no line breaks in proper places... can you put it in pastebin please?

  8. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Anyone have any other thoughts on this?

  9. GreenLead
    Member
    Posted 2 years ago #

    I had the exact same problem last night. Luckily, I managed to resolve this :)

    In the Theme Editor, go to single.php and add the following:

    <?php get_sidebar(); ?>

    In a new line just above the footer code at the bottom of the file:

    <?php get_footer(); ?>

    Next, go to functions.php (Theme Functions) and find the following at the bottom of the file:

    add_filter( 'body_class', 'twentyeleven_body_classes' );

    Comment it out and it will force WordPress to stop differentiating between normal and single post pages.

  10. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    I am using a child theme, how does one comment out a child theme function.php line of code? Is there a remove filter?

  11. GreenLead
    Member
    Posted 2 years ago #

    I didn't bother with child themes - I directly edited the original Twenty Eleven files.

    Not necessarily recommended practice, but it was a quick and dirty solution that worked for me.

  12. Noooo, don't do that.

    Unless you enjoy debilitating pain and suffering then yes really, you don't want to do that. Ever. ;)

    Editing the Twenty Eleven theme is always a bad idea.

    Follow the instructions in the Child Theme article.

    http://codex.wordpress.org/Child_Themes

    Now in the new themes/twentyeleven-child directory make a copy of themes/twentyeleven/single.php (this is from the parent theme).

    Edit the child theme copy of single.php and not the parent theme and add that <?php get_sidebar() ?> as above.

    Do not make a copy of the parent theme's functions.php file instead create a new one with just these lines.

    <?php
    add_filter( 'body_class', 'mh_remove_body_classes' , 50 );
    function mh_remove_body_classes() {
       remove_filter( 'body_class', 'twentyeleven_body_classes' );
    }

    The child theme's functions.php file gets run first, so we need to add the remove_filter() to the filter queue at a priority that guarantees the it runs later. That's what the , 50 ) does.

  13. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    I finally resolved this.

    A) added:
    <?php get_sidebar(); ?>

    just above the footer code at the bottom of the Child Theme's single.php (which is just a copy of the original one with this mod):

    <?php get_footer(); ?>

    B) Added:

    remove_filter( 'body_class', 'twentyeleven_body_classes' );

    at end of my the child theme's functions.php file.

    C) Adjusted the CSS to go along with my already customized css (mostly to get rid of the huge gaps in the default theme):

    .singular #content, .singular.left-sidebar #content {
    	margin-left: 24%;
    	margin-right: 2%;
    }

    Probably will tweek css a bit but the sidebar now displays without an overlap of the post content.

  14. Jbram
    Member
    Posted 1 year ago #

    Is there no way to just strip all singular classes or what ever, and have the single posts behave exactly as the pages?

    I made a child theme, added the <?php get_sidebar(); ?>. But the CSS you have to deal with to make it look just like the pages. It just seems wrong. I don't know much about php. But can't I add a function that just eliminates all CSS classes that changes the layout from default.

    It puzzles me how someone can decide to create the option to choose between left, right or no sidebar, and then basically only have that choice count on the homepage.

  15. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    Did you add the remove filter to your child theme's functions.php?

    remove_filter( 'body_class', 'twentyeleven_body_classes' );

    ??

  16. alchymyth
    Forum Moderator
    Posted 1 year ago #

    Is there no way to just strip all singular classes or what ever,

    there is - see my post.

    to adjust the body_class output so that a sidebar in the single post layout of Twenty Eleven (in a child theme) behaves in the same way as the sidebar on the main index page,
    basically, you add a filter to functions.php in the child theme;

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

    credit goes to these resources:
    http://dev-tips.com/featured/remove-an-item-from-an-array-by-value
    http://wordpress.stackexchange.com/questions/15850/remove-classes-from-body-class

  17. Jbram
    Member
    Posted 1 year ago #

    Thanks for the advice.

    I ended up using this plugin http://moztools.com/wordpress/theme2011-plugin/.

  18. Big_Birtha
    Member
    Posted 1 year ago #

    Hi, I followed Jan Dembowski's instructions, and it looks great on Firefox, except I get this message under my WordPress bar:

    Warning: join() [function.join]: Invalid arguments passed in /home/content/44/10371344/html/wp-includes/post-template.php on line 389
    class="">

    ???

    I checked in Chrome and there is no change - i,e, no sidebar.

    I tried alchymyth's option, but that gave me this error message:

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/44/10371344/html/wp-content/themes/twentyeleven-bigbirthas/functions.php:17) in /home/content/44/10371344/html/wp-includes/pluggable.php on line 876

    And didn't make the sidebar appear anyway.

    I don't want to use the Moztools plugin because it's not been tested with the latest version of WordPress and it also messes up my bbpress forum page (which I took ages getting right)

    Any ideas gratefully received.

    The website is bigbirthas.co.uk if that helps anyone.

    Many thanks

  19. Andrew
    Forum Moderator
    Posted 1 year ago #

    @Big_birtha, you can discuss that in your own thread.

  20. Big_Birtha
    Member
    Posted 1 year ago #

    but why? Isn't it relevant to discuss it here, where the solutions have already been offered and don't (quite) work?

    Besides, I've asked my own questions on two other threads and received no responses at all :o(

    I'd really like Jan Dembowski's response as he had the grace to add his solution here which so nearly works for me.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.