Archived topic
Custom layout depending on category
3 replies · Started by Robert on March 31, 2023
My default layout is content + right sidebar.
What I am trying to do is to check whether a post is in the category 'X'. If yes, use the layout content (no sidebars) instead.
How can I do that?
Hi there,
You can use a layout element to achieve this, no code is required.
https://docs.generatepress.com/article/layout-element-overview/#sidebar
yes but is there a way to make it work with code? it would work better for me because I sometimes forget to set the layout element so I want to make it category specific instead.
In that case, try this filter: https://docs.generatepress.com/article/generate_sidebar_layout/