Archived topic
Change column count for specific category
3 replies · Started by Dan on August 9, 2018
Hi
I am trying to change to a 1 column blog layout for 2 specific categories.
The problem is that it causes all categories to have 1 column.
I have set 3 columns in the customizer.
This is showing up correctly with 1 column (category 183):
https://www.golancoalition.org/recent-developments_en/
This category is showing incorrectly (1 column instead of 3):
https://www.golancoalition.org/publications/
This is the code I used in the functions file:
add_filter( 'generate_blog_get_column_count','generate_custom_column_count' );
function generate_custom_column_count(){
if ( is_category( '183' ) ){
return 100;
}
if ( is_category( '185' ) ){
return 100;
}
// Or else, return the default
return $count;
}
Removing this function brings back 3 columns for all categories.
Thanks,
Dan
Hi there,
There are mistakes in the code. Try this instead:
add_filter( 'generate_blog_get_column_count','lh_category_column_count' );
function lh_category_column_count( $count ) {
if ( is_category( array( 183, 185 ) ) ) {
return 100;
}
return $count;
}
Note that you didn't specify which variable it should return in the this line:
function generate_custom_column_count()
Thanks Leo,
That did it.
Dan
No problem :)