Hi,
Is there any option to disable sidebar inside every single post? My web has more than 100 posts and I do want them to be displayed with no sidebar.
Anything I can do inside php archives?
Kind regards.
Hi,
Is there any option to disable sidebar inside every single post? My web has more than 100 posts and I do want them to be displayed with no sidebar.
Anything I can do inside php archives?
Kind regards.
Hi Pilar
Good to hear from you.
I will be online in a few hours and will send some ideas.
If possible, please don’t spend more time on this problem until then as I can hopefully save you some time. I have a few ideas.
Chat further then 🙂
Sent from phone, please excuse any typos.
Sorry for the delay.
My preferred option would be to use Jetpack Widget Visibility. Once Jetpack is activated and Widget Visibility is enabled you can go to Appearance > Widgets and set negative display conditions for each widget. If each widget is set to not display on single post, the sidebar won’t display. This would also count as theme independent solution.
If you’d like to disable all Jetpack modules except for Widget Visibility, see this post to find the old Jetpack module overview page: https://purothemes.com/view-jetpack-modules-one-list/
Let me know what you think of this solution and we’ll go from there 🙂 Thanks.
There is no cleaner solution? Something like hardcoding Polestar page template (no sidebar), or a php instruction to be included in single.php or single-post.php?
Installing Jetpack only for this sidebar issue… is a little bit extreme.
Jetpack with all modules except for Widget Visibility disabled is a lightweight solution. It’s also theme independent. WooSidebars would be another option.
No problem. I can help you set this up in a child theme. It’ll require that you use Customizer Import/Export to move your settings from the parent to the child. I’ll send that a bit later.
Once I’ve sent the child theme, here is how you’ll migrate your settings from the parent to the child theme: https://purothemes.com/customizer-settings-export-import/. If you’re already using a child theme then this wouldn’t apply.
Hi Andrew,
thanks for your fast response. I am currently working under a child theme (you know, it’s one of the wordpress best practices), so that step is already done.
Let’s say that I am a sort of web developer, so my knowledge is a little bit higher than average ;).
Regards.
Super 🙂 Copy single.php from the parent to the child theme and remove get_sidebar(); on line 48. That’s it 🙂
I did so a week ago, but the result is that page is not full width. Sidebar was deleted, yes, but content was not extended into sidebar block 🙁
Content box remains split in two.
Is there any way to full-size that content or to tell the system that layout to use is «no sidebar» one?
The theme still sees widgets active in the sidebar widget area so it’s adding a body class for that and then CSS rules target that class. To change that, try adding to your Custom CSS or child theme style.css file:
.single.sidebar .content-area {
width: 100%;
}(Just for reference sake, the advantage of the Widget Visibility method is that the sidebar is seen as empty so the sidebar class isn’t added to the body tag and the theme stylesheet will style the single post as full-width.)
Thank you Andrew,
I’ll do it in a CSS way then. You know that sometimes themes create specific php functions for this template selection and changes are as easy as including a php call inside single.php template but… this way is good enough.
Kind regards
Sure.
The setup is quite easy to follow, you can also filter out the sidebar body class if you wanted.
Sidebar called in single:
https://github.com/purothemes/polestar/blob/master/single.php#L48
If the sidebar widget area is populated, add a class name to the body tag:
https://github.com/purothemes/polestar/blob/master/inc/extras.php#L46-L49
If the sidebar class is present in the body tag, setup the container widths as required:
https://github.com/purothemes/polestar/blob/master/sass/site/_layout.scss#L27-L41
Unfortunately, there isn’t a global setting to remove the sidebar from single posts. Options are:
1. Widget Visibility module.
2. WooSidebars plugin.
3. Child theme, remove the sidebar from single and override the the layout with a custom CSS rule.
4. Child theme, remove the sidebar from single and filter out the unwanted body class with a conditional statement for when you want it removed. Something like this: https://wordpress.stackexchange.com/questions/15850/remove-classes-from-body-class
Hope that helps explain what’s going on there.