• Resolved Pioneer Web Design

    (@swansonphotos)


    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. https://www.gfld82.com/test-post/

Viewing 15 replies - 1 through 15 (of 19 total)
  • please provide a tip on how to go about having both posts and pages use the same sidebar/widget setup

    Try a forum search? :
    https://www.ads-software.com/search/Twenty+Eleven+Child+Theme+Single+Post+Page+Sidebar?forums=1

    Thread Starter Pioneer Web Design

    (@swansonphotos)

    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?

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

    there never was one.

    try a plugin https://www.ads-software.com/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 https://www.transformationpowertools.com/wordpress/twenty-eleven-sidebar-on-single-posts-and-pages

    Thread Starter Pioneer Web Design

    (@swansonphotos)

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

    Thread Starter Pioneer Web Design

    (@swansonphotos)

    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?

    Thread Starter Pioneer Web Design

    (@swansonphotos)

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

    Thread Starter Pioneer Web Design

    (@swansonphotos)

    Anyone have any other thoughts on this?

    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.

    Thread Starter Pioneer Web Design

    (@swansonphotos)

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

    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.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    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.

    https://codex.www.ads-software.com/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.

    Thread Starter Pioneer Web Design

    (@swansonphotos)

    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.

    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.

    Thread Starter Pioneer Web Design

    (@swansonphotos)

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

    remove_filter( 'body_class', 'twentyeleven_body_classes' );

    ??

    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:
    https://dev-tips.com/featured/remove-an-item-from-an-array-by-value
    https://wordpress.stackexchange.com/questions/15850/remove-classes-from-body-class

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Twenty Eleven Child Theme Single Post Page with Sidebar’ is closed to new replies.