Archived topic
Custom Columns Layouts for Categories
3 replies · Started by Former User on January 25, 2021
Hello,
I have two blog post categories and I would like to have custom column layouts for each of the categories.
The podcast category has 3 columns which was easy to set up through the customizer.
Now I would like the blog category to remain centered without any columns.
I have looked through the forum but somehow I could not make it work.
Maybe because I am confused what to enable or disable in the customizer when adding a php code.
Any ideas?
Podcast Category:
How I would like the blog category to look:
Thanks!
Hi there,
you can do it with some CSS:
.category-blog .generate-columns-container .post {
width: 100%;
}
Hello David,
thank you very much! It worked like a charm.
I also added this php snippet from Tom to make sure that the sidebars for this specific category are enabled:
add_filter( 'generate_sidebar_layout','generate_custom_category_sidebar_layout' );
function generate_custom_category_sidebar_layout( $layout )
{
// If we are on a category, set the sidebar
if ( is_category( 'Blog' ) )
return 'both-sidebars';
// Or else, set the regular layout
return $layout;
}
Glad to be of help :)
As a note - you can use the Layout Element to make changes like sidebars etc.
https://docs.generatepress.com/article/layout-element-overview/