Duplicate and alter sidebar for Twenty Eleven

I’m trying to create own template including submenu instead of the regular sidebar in Twenty Eleven.

Although I manage to create and select my new template the page ends up with bad CSS.

Read More

Here is what i have done

  • Copy sidebar-page.php and named it submenu-page.php
  • Copy sidebar.php and named it sidebar-submenu.php

In submenu-page.php

Added new template name “Sidebar left menu template” and changed

<?php get_sidebar(); ?>

to

<?php get_sidebar('submenu'); ?>

In In sidebar-submenu.php

Replaced all code with Hello World-link.

Even tough Hello World appears correctly the link is uncklickable due the div #primary is all over the page.

For unknown reason the HTML-body gets both singular and two-columns as value in the class attribute. If I edit sidebar-page with get_sidebar(‘submenu’) everything looks and works great.

How do I tell wordpress that my template (submenu-page.php) is two columns and not both single and two columns?

Thanks for your time!

Related posts

Leave a Reply

1 comment

  1. the layout is controlled by the .singular css class, which in turn is generated in functions.php depending on the template.
    in your child theme of Twenty Eleven (if you don’t have a child theme, create one first) add this code to functions.php:

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

    if you want to make the change in Twenty Eleven directly, edit functions.php, near the bottom (code shown after the edit):

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