Archived topic
Having 3 columns on one blog and 2 on another
3 replies · Started by Ema on April 5, 2021
Morning GP team!
I have a standard blog which would like 3 column layout (which I can do with the customiser).
I have a second blog 'News' set by category, which I would like to display as 2 columns.
I have the filter here
add_filter( 'generate_blog_get_column_count', function( $column_width ) {
if ( is_front_page() ) {
return '50';
}
return $column_width;
} );
I'm not sure what to change in the filter to target this page - if the (is_front_page() ) {
I would change this to 'is_news' ?
Is this ok to add in hooks?
page link below
Best Ema
Hi there,
you can use the is_category template tag:
add_filter( 'generate_blog_get_column_count', function( $column_width ) {
if ( is_category( 'news' ) ) {
return '50';
}
return $column_width;
} );
The add_filter is a Hook itself and needs to be parsed before the template it output - which means they cannot be used in the Hook Element. This article explains how to add them:
https://docs.generatepress.com/article/adding-php/
TLDR: If using a Child Theme, put them in the child themes functions.php, if not use the Code Snippets plugin
Magic - David.
Works brilliantly.
Thanks so much for your time and expertise.
best Ema
Glad to be of help!