Add Sidebar to Page and Single Post in WordPress Twenty Eleven Theme
By Craig Mazur | August 2, 2011 | Copyright 2011 - All Rights ReservedIf you have started working with the new WordPress Twenty Eleven theme that comes with WordPress 3.2.x, you probably noticed that the menu sidebar is missing from the default page and post pages.
With the older default WordPress themes, to add the sidebar all that you needed to do was to add the get_sidebar() function to the code for the appropriate theme script. With the Twenty Eleven theme, there is an additional step that must be taken. If you simply add the sidebar code, the theme breaks and the sidebar ends up below the content.
Why did the WordPress team remove the menu sidebar? Who knows. There doesn’t seem to be any obvious logic to this, but there does seem to be a trend to simplify the page display. In my humble opinion, the sidebar menu is important for both search engine optimization and user friendliness.
I found the solution that works in this post: Add sidebar to single post in the WordPress 3.2 Twenty Eleven theme. The fix works for both the default page and the single post. The theme script for the default page template is page.php. The theme script for the single post page is single.php. Both scripts should be modified.
The first step is to add the get_sidebar function to both the page.php and single.php scripts. Add the function just above the get_footer function. After doing this, the sidebar will be added, but it displays below the content.
</div><!-- #content --> </div><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?>
The second step is to disable a function in the functions.php script that is creating the layout issue. Open functions.php in your editor and scroll to the bottom. It is the very last function. Simply comment out the function to disable it. You can use any valid method to comment out the code to disable it or you can simply remove the code. It might be best to keep the code just in case a need for it is discovered in the future.
/*
function twentyeleven_body_classes( $classes ) {
if ( ! is_multi_author() ) {
$classes[] = 'single-author';
}
if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
$classes[] = 'singular';
return $classes;
}
add_filter( 'body_class', 'twentyeleven_body_classes' );
*/
Other Problems with the Twenty Eleven Theme
The Twenty Eleven theme relies heavily on HTML 5 features that do not yet exist with current browsers and therefore do not work. The current workaround for this is to add browser-specific JavaScript code that simulates the missing features. The problem with this is that the theme breaks when JavaScript is disabled in a user’s browser.
I saw an article that mentioned a quote from a WordPress team member where they did an investigation and found that only about 1% of users have JavaScript disabled, so the number of users who would have problems was deemed to be insignificant. The flaw in this logic is that any user who sets the security level to High in Internet Explorer disables active scripting, which also disables JavaScript.
I don’t know where the WordPress team got their data, but the W3 Schools surveys indicate that currently about 5% of users have JavaSctript disabled.
If you are using the WordPress Twenty Eleven theme for business sites, 5% is a significant number. You might want to consider using Twenty Ten or a different WordPress theme for business purposes.



ryan Says:
doesn’t work
Smitty Says:
Then you are missing something in the instructions. I’ve followed these instructions several times and it works perfectly for me every time.
This only works with the Twenty Eleven theme and will not work unless you comment out the function.
Until Twenty Eleven came along, all that you had to do is add the get_sidebar function. Twenty Eleven is a real mess and is much more difficult to work with than other themes.
Blake Erickson Says:
Thanks, I got it to work. Now I just need to figure out how to make the comments wider now because with the sidebar they have become quite narrow.
Lawrence Snow Says:
Thank you soo much! I have been looking for this solution for such I long time. I was missing the page.php piece. Awesome!
Petra-S Says:
Thank you so much – it works perfectly!