WordPress.org

Support

Support » Themes and Templates » [Resolved] 2011 – creating a template file from sidebar-page.php / bod y class issue (width

[Resolved] 2011 – creating a template file from sidebar-page.php / bod y class issue (width

  • Hello.

    I’m used to working with 2010 where you can create a custom template file based off either the one or two column layout by using the content .one-column class.

    I’m having a hard time trying to figure out how to create a two column template in a 2011 child theme. I’ve got the sidebar, I’ve just got the wrong content widths going on.

    I took the 2011’s sidebar-page.php file and renamed it (both file name and in the header of the file) to home-page.php / * Template Name: Homepage Template. The rest of this file is exactly the same as sidebar-page.php.

    SO… why isn’t the layout width of the content area the same?

    I can see this new template file is getting the body classes of; singular two-column right-sidebarhttp://ratest10.com/

    while a page using the default sidebar-page.php template file gets the body classes of; two-column right-sidebar. http://ratest10.com/?page_id=2

    How the HECK do I get rid of that ‘.singular’ body class in my new template file (because when I remove it in FireBug I know that is where my problem is).

Viewing 1 replies (of 1 total)
  • Ok, I dug around and found this http://www.transformationpowertools.com/wordpress/twenty-eleven-new-page-template-with-sidebar-correction

    I then added this to my functions.php file (noting that home-page.php is indeed the name of my new template file).

    add_filter('body_class', 'adjust_body_class', 20, 2);
    function adjust_body_class($wp_classes, $extra_classes) { 
    
    if( is_page_template('home-page.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 );
    }

    … it was so much easier in 2010.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] 2011 – creating a template file from sidebar-page.php / bod y class issue (width’ is closed to new replies.
Skip to toolbar