With the new TwentyEleven template included in WordPress 3.2 you’ll notice that the sidebar is gone in the single post page.
Update: This solution has succesfully been tested for the new WordPress 3.3 update and TwentyEleven 1.2 update.
Remark: This solution also works for single pages. Instead of single.php add the <?php get_sidebar(); ?> to page.php as described below for single.php
Based on the comments on http://futurewebblog.com/add-sidebar-support-posts-twenty-eleven-theme/ i’ve described my quick workaround below. It looks like the sidebar issue can be solved by just editing 2 files in the editor, which you can find in the Appearance menu.
Step 1:
In the single.php file replace:
</div><!– #primary –>
<?php get_footer(); ?>
With:
</div><!– #primary –>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Press ‘Update File’.
If you open a single page you will see the sidebar has appeared on the single post page, but it is at the bottom of the page.
Step 2:
To put the sidebar next to the post, we have to edit the theme functions (functions.php)
Open the functions.php in the editor.
The statement you’ll be looking for is the ‘singular’ statement, found at the bottom of functions.php. I’ve added comment tags to be able to switch back to the original situation without too much trouble. But i advise to back up the original file just in case something goes wrong.
This is how i’ve done it:
/**
*add_filter( ‘body_class’, ‘twentyeleven_body_classes’ );
*/
As you can see i’ve added the /** in front of the first part, and added an * to each line, to close the ‘comment mode’ just add a line with a */.
All you have to do is press the ‘update file’ button and you’re set.
This is just a quick fix which seems to fix the problem for me, I don’t know much about php so i’m sure there are better ways to fix this problem. If so, please let me know.
i’ll try this
hi i tried your suggestion and it work for single post except that sidebar doesn’t show on the single page. i’m happy about this tip. one more thing, i think the: should be anyway i didn’t changed that part on single.php i just added: you can check it here: http://archivistblog.info/what-is-cloud-computing/ i just hope it won’t have any problem in the future
I hope the same trick works for page.php. I’ll give it a shot and give you a shout.
Looks like it works for page.php as well by just adding the statement in page.php See above for an update.
hi. you mean just add this: to the page.php
It looks like wordpress removes this code from the comment, so i didn’t see it in your comment too. I guess we’re both talking about the get_sidebar statement
yeah, the get_sidebar thing i posted was not shown.
yep that’s what i’m talking about.
Suffice comment out //$classes[] = ‘singular’;
Thanks! I’ve tested this, but it doesn’t seem to work. You mean commenting out only 1 line of code?
Does anybody know how to nix the function using a child theme?
Have a look here, they are providing a child theme:
http://futurewebblog.com/add-sidebar-support-posts-twenty-eleven-theme/
I was hoping for a function-based solution since my child theme has different measurements. I may actually have to do the calcs myself!
Pingback: Anonymous
hi, can i get a web blog, or else to refer how to edit this twenty eleven look nice and clean..thanks
or hope you can give us a tutor how to edit twenty eleven.
The editting of the 2 php files was the only thing I did, apart from adding some widgets. The rest is pretty standard. Let me know what kind of changes you are looking for.
How I can to add another sidebar in the index of the template. Anybody help me, I’m novice in wordpress
Twenty Eleven doesn’t support multiple sidebars right out of the box. You should look for a template with multiple sidebar support. Before the update i’ve worked with the pagelines theme and used 2 sidebars next to eachother. Just search for ‘pagelines’ in the add new theme section of your dashboard.
This was extremely helpful — thank you for this.
Followed your instructions and got it to work perfectly. Thank you so much. Now if I could just get my nested comments to look like yours. How did you do that?
Thanks again
Katie
head-heart-health.com
You’re welcome
I didn’t customize the comments as far as I know. Is your “Enable threaded (nested) comments 5 levels deep
” ticked at the Settings -> Discussion page?
I believe they were were referring to the alternating, colored threading.
Pingback: How To Add The Sidebar To Twenty Eleven
Pingback: Adding the sidebar to a Twentyeleven child theme | iamtgc
Hi, thanks a lot for this as it’s exactly what I’m trying to do (with a child theme) …but the single.php doesn’t have that code in it. I think it may have changed with the recent update so grateful if anyone can help please.
I understand you don’t have the ‘php get_footer’ in your single.php?
What if you just add the ‘php get_sidebar’ line as described above?
It works ok! Thanks a lot!
it’s work..thank you..
i want to ask..how to insert wp-page number in twenty eleven theme??
I don’t have experience with the wp-page number plugin, it isn’t working in the twentyeleven theme?
It works perfect! If in doubt then check my wordpress page out http://onlinesoccergames.biz/blog/?p=5
Thanks !!!
OK! Thanks !!!
I’ll try it.
Bart, thanks much for this — was so happy to find. But then when I upgraded the client’s site, of course the parent functions.php was refreshed and I got the call asking why the sidebar was messed up. {face-palm}
What to do when using a child theme? But thanks to @mor10 and his excellent tutorial at Lynda.com on child themes, I think I have the solution. It seems to be working. I’ll paste the code below. Of course, one can name the function whatever you want.
// remove the default function that makes single items etc. have different sidebar
function cf_fix_sidebarissue() {
remove_filter( ‘body_class’, ‘twentyeleven_body_classes’ );
}
add_action(‘after_setup_theme’, ‘cf_fix_sidebarissue’, 11);
Hi,
I was trying to create a page sidebar different from the blog sidebar. But being a complete noob in WP, I was not able to do that. Can you please help me to do that? Or can you please release a child theme, so that the page sidebar template uses a different sidebar with different sets of widgets?
Thank you in advanced. I’ve also posted this problem on WP Forum, but not having so much help there.
I guess there are plugins for this. I’m using widgets that are based on categories, but it also works for pages. I use “Related Posts Widget” http://jameslao.com/2010/01/01/related-posts-widget-1-0/ to show different sorts of ads with diferent kinds of content.
Have a look on these sites for more info about child themes, I haven’t really gotten into that.
http://futurewebblog.com/add-sidebar-support-posts-twenty-eleven-theme/
http://www.gentlewisdom.org.uk/3947/wordpress-twenty-eleven-give-us-back-our-sidebar/
And maybe Cheryl’s reply above can help you out
Hope it helps!
Thanks for the suggestion. Well … I have got a solution here. This is what I actually wanted.
Much thanks, I was like “WTF” when I saw that this theme didn’t have the sidebar on single posts. But your code worked like a charm : )
Hi Bart,
thank you very much for this wordpress. As you can see on my website http://www.remarkableheadlines.com it is working absolute great! Thanks again, have been searching a lot but couldnt find a tut that was as good as this!
Hello,
this fix works, however it results in very narrow comments (as also seen on your site). How would one go into spreading the comments so they cover the full width of the main content area?
Good point, i’m afraid this isn’t possible within the twentyeleven theme, i’ll have a look.
Hello Bart,
any luck with this?
:S
Haven’t been able to make it work for my blog, maybe you can try to disable nesting? so the posts don’t get crammed up like this.. Good luck
Pingback: Ayuda Webmaster | Añade el sidebar a los post en Twenty Eleven Theme
Hi Bart
This works perfectly – thanks for the fix.
So annoying that wordpress did this – cant think of a legitimate reason why.
On another related question – how did you install the fantastic floating social bookmarking buttons (twitter, facebook) that I can see on this page, to the left of the content column? Is it a wordpress plugin? Would be great if you could let me know where to get it
Many thanks
Paul
Hey Paul,
Good to hear you restored your sidebar.
Check out http://surminski.eu/2011/08/15/add-floating-social-share-buttons-to-wordpress/ to get the toolbar.
Let me know if you need any assistance.
Works for me
Solved the comments problem (finally!) – here’s the fix — change this in your style.css (search for these exact values and change just the items I’ve edited, or just paste this at the very bottom of the stylesheet):
#respond {
width: auto;
}
.commentlist {
width: auto;
}
.commentlist > li.comment {
margin: 0px 0px 20px 102px;
width: auto;
}
You can edit the top margin value to whatever you want. The 102px margin is required for the default avatar.
PS my gravatar says admin, but I’m not an admin here
Thank you very much for your help
I was able to follow your instructions and succeeded, but instead of putting stars in front of each line I just started with this /* and then after all of that code at the end I added this */ and it works.
You’re right, this also works and makes the code ‘cleaner’. But as a non-coder I prefer this since it shows in one glance that the complete code is between comment tags
I added the codes to the single.php and functions.php pages, but the sidebar still shows up at the bottom, after the post ends. Any thoughts on a fix? Here is an example?
http://www.gastrofine.com/2011/08/grilled-chicken-with-quinoa-cucumber-salad/
Hello John, i’m not sure what is going wrong, can you add the code to page.php and check if it does appear next to or under your ‘about’ page.
Pingback: 1. September 2011 bis 2. September 2011 | word of mouse
I followed your exact instruction and worked like charm! Thank you!
Pingback: Боковая панель на всех страницах Worpress | ExtraLAN.ru
Thank you, thank you! This worked and seems to be a very clean solution. Once WordPress upgrades and the functions.php file gets updated hopefully the change will again be easy to implement.
Hy there.
i was looking for a nicer way to do this.
Basicaly you need to do 2 things so the site still work good.
Make a copy of the single.php and name it one-column-page.php
Add this lines at the top of the page.
/**
* Template Name: One Column No sidebar
*/
Because we don’t whant the singular class to apear when is single post you must tell that function if it is singular don’t show singular class. that is done by puttin ” ! ” in front of is_singular() and to tell to show the class when accesing the new template is_page_template( ‘one-column-page.php ‘ )
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’ ) && is_page_template( ‘one-column-page.php ) )
$classes[] = ‘singular’;
return $classes;
}
add_filter( ‘body_class’, ‘twentyeleven_body_classes’ );
Now you should have the posibility of chosing no column for pages.
Hi Bart,
You are a genius. That worked great!!!
This worked perfectly! Thank you so much, it was really easy to follow.
Thanks !!!
In my case I just have to add in single.php page. And Done. Easy Job. Thanks…
added this one.
Hey,
Thanks dude.. It works perfectly. Actually I’ was in a big trouble how to solve this. I was thinking about to switch back to twentyten theme. But this tutorial helped me.
Thank you so much Bart. Cheers
Actually in step two you just need to comment THIS line
// add_filter( ‘body_class’, ‘twentyeleven_body_classes’ );
If you don’t run “add_filter” the function won’t do anything, but it’ll be there for reference if you need to restore it it’s way easier to just uncomment one line.
Cool, I’ll check it out, thanks
Works like a charm, i’ve editted the post, thanks!
Traveled a long grapevine to get to your extremely helpful post here. I like it when things are as easy as following instructions. Thanks!
Thank u so much for this easy Tutorial.
It works well.
I just wanted to thank you for posting a fix to the side bar problem. At first, I was a bit hesitant but decided to try it and I followed your instructions exactly. I have no programming experience whatsoever and I had the sidebar problem solved in about 10 minutes. Thank you again!
Thanks I went crazy trying to show the sidebar on my new wordpress blog and this piece of code did the job perfectly. Very helpful.
Done the job for me. Thanks! Took me a few minutes to work out exactly what to do on item two but that was probably because I wasn’t switched on!
This solution worked for me except the side bar is not showing on the single pages. I would like it to show on the single pages as well.
By the way, love the TwentyEleven wordpress theme. Thanks!
So it works on the page.php but not on the single.php?
This worked perfectly on my blog. Thank you so much!
Thanks, Bart!!! It worked a treat. I salute you, sir.
Great post. Just wondering about two things:
1. Is it possible to reduce the space between the ‘Next’ and ‘Previous’ buttons at the top of the page and the post title?
2. Is it possible to change the appearence of the header in posts. I have a large description of my blog on the home page which by default appears at the top of each page but I’d prefer if it only appeared on homepage. Can you tell me what to do for this?
If you need to look at my site to see what I’m talking about, it’s here: http://www.digitalmarketingnerd.com
Thanks Paul
1: I’ll look into this, it might be a simple change in the edittor -> i’ll let you know.
2: Seems to me you typed quite a lot of info in the settings -> general -> tagline field. It’s only meant for a few words to act as a ‘subtitle’ to your blog name. A solution might be to add a page to your blog with the name ‘Home’ and put the text on that page. Then in settings -> reading, choose you want to use a static page and select the page you just created as home page. I think you have to create a new page to be used as your ‘blog’ page. If you run into any trouble with it let me know.
Another workaround to keep that text on the homepage is to put it in a new blog post, and make that post sticky so it always shows on top on your current page, this might be the quickest way to reach your goal.
Ok so I feel stupid for not being able to figure this out but where exactly do I put the line for the second part? Maybe if you could show it similar to step one that would help muchly. Thanks.
Nevermind, I figured it out
. Thanks!
Glad you fixxed it
Thanks!!
Excellent work
thx man
i post this article in my blog
have a good night
Good to hear! And fun to see the scrollbar on the left site of my screen when i open your site
Take care
Pingback: حل مشکل نمایش ندادن سایدبار در تک نوشته در قالب Twenty Eleven « مجله اینترنتی یک تب
Thanks! Worked like a charm!
what work should i do?
Just what I was looking for to fix that theme. Worked like a champ – thank you!
Pingback: حل مشکل نشان ندادن سایدبار در تک نوشته در قالب Twenty Eleven « مجله اینترنتی یک تب
This worked well for me with one small problem: the post-entry-meta text (posted on ) collides with the sidebar (because I have it on the left, and am hiding the black menu under the images. If I add some CSS to say, put it even with the title, (about 180 pixels or so), than it’s fine on the post pages, where it is above the title (and even with the ‘<—Previous' nav link). However, now on the home page, all the posts have it moved as well! Is there a way to change the post-entry-meta locations on just the single post pages? Thanks for any tip you can provide…
Simplest instructions I have found, as of yet (for us very not familiar with coding out there)!! Thank you so much!