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

  • Resolved AardvarkGirl



    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-sidebar

    while a page using the default sidebar-page.php template file gets the body classes of; two-column right-sidebar.

    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

    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]);
    // 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 ‘2011 – creating a template file from sidebar-page.php / bod y class issue (width’ is closed to new replies.