- This topic has 11 replies, 2 voices, and was last updated 6 years, 11 months ago by Andrew Misplon.
- AuthorPosts
- December 1, 2017 at 11:56 am #8376
Pilar Navarro ColoradoParticipantHi,
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.
December 1, 2017 at 12:13 pm #8383
Andrew MisplonKeymasterHi 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.
December 1, 2017 at 7:37 pm #8385
Andrew MisplonKeymasterSorry 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.
December 4, 2017 at 10:37 am #8406
Pilar Navarro ColoradoParticipantThere 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.
December 4, 2017 at 10:50 am #8407
Andrew MisplonKeymasterJetpack 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.
December 4, 2017 at 11:44 am #8408
Pilar Navarro ColoradoParticipantHi 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.
December 4, 2017 at 11:46 am #8409
Andrew MisplonKeymasterSuper 🙂 Copy
single.php
from the parent to the child theme and removeget_sidebar();
on line 48. That’s it 🙂December 4, 2017 at 12:31 pm #8410
Pilar Navarro ColoradoParticipantI 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?
December 4, 2017 at 12:36 pm #8411
Andrew MisplonKeymasterThe 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%; }
December 4, 2017 at 12:38 pm #8412
Andrew MisplonKeymaster(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.)December 4, 2017 at 1:39 pm #8413
Pilar Navarro ColoradoParticipantThank 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
December 4, 2017 at 1:50 pm #8414
Andrew MisplonKeymasterSure.
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#L48If 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-L49If 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-L41Unfortunately, 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-classHope that helps explain what’s going on there.
- AuthorPosts
You must be logged in to reply to this topic.