WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Eleven
[resolved] New Sidebar Template Not Working in Twenty Eleven (6 posts)

  1. progresst
    Member
    Posted 2 years ago #

    I have a new installation of WP and am using Twenty Eleven. On this page I use the Template: Sidebar Template which from what I can tell uses the sidebar-page.php and it displays fine:
    http://tinyurl.com/3fdyzd4

    I make an EXACT copy of the sidebar-page.php to another file called sidebar-preinsulated.php and choose that as the Template: Sidebar Template Preinsul for this page and the sideline suddenly drops down below the content:
    http://tinyurl.com/3ptn7dv

    I have compared both pages using Firebug and cannot figure out why simply changing the file name and choosing this as the template is breaking this page? It appears to be exactly the same? What am I missing?

    http://wordpress.org/extend/themes/twentyeleven/

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

    don't edit twenty eleven directly; create a child theme and make the edits there.
    it is important to have an unedited default theme in case of theme problems. also, any customisations of twenty eleven will be overwritten with the next upgrade of your wordpress version.

    about the sidebar:
    look into functions.php of Twenty Eleven, a few lines from the end:

    if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )

    that is the section where the sidebar appearance is controlled.

    ---
    in the child theme of twenty eleven, add this to functions.php: http://pastebin.com/QVcpPus9

    this should get your sidebar and page into the right position.

  3. progresst
    Member
    Posted 2 years ago #

    @ alchymyth...awesome, thanks!

  4. mb studio services
    Member
    Posted 2 years ago #

    I have added the following code to my child functions.php file,

    add_filter('body_class', 'adjust_body_class', 20, 2);
    function adjust_body_class($wp_classes, $extra_classes) {

    if( is_page_template('sidebar-preinsulated.php') ) :
    // Filter the body classes

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

    I have more then one page template and this piece of code only works for one page template. Is there a way to modify this to add additional page templates ?

    Thanks,
    Mike

  5. alchymyth
    Forum Moderator
    Posted 2 years ago #

    put all page template files using the || (OR) operator into the if statement:

    if( is_page_template('sidebar-preinsulated.php') || is_page_template('another-page-template.php') || is_page_template('more-page-template.php') ) :
  6. mb studio services
    Member
    Posted 2 years ago #

    Thank you for your help, that worked like a charm !

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic