Archived topic
Columns for Categories
5 replies · Started by Math on June 15, 2021
Hi,
I would like to maintain a single column look for the archive page as it is now (https://doodle.house/journal). But I would like to make the categories to be 2 columns (https://doodle.house/category/merch-styling).
I tried adjusting the columns in the layout option but it seems to be impacting both Archive and Categories. Is there a way around it?
Thank you.
Hi there,
You can use this filter:
https://docs.generatepress.com/article/using-columns-in-the-blog/#adding-columns-to-your-custom-post-type
With a conditional tag:
https://codex.wordpress.org/Conditional_Tags#A_Category_Page
Hi,
I tried placing the following snippet into functions.php, but doesn't seem to be working.
add_filter( 'generate_blog_get_column_count','db_tax_archive_column_count' );
function db_tax_archive_column_count( $count ) {
if ( is_category() ) {
return 33;
}
return $count;
}
Is the columns option in the customizer?
https://docs.generatepress.com/article/using-columns-in-the-blog/
If not then you will also need this:
https://docs.generatepress.com/article/using-columns-in-the-blog/#adding-columns-to-your-custom-post-type
I used the following and it worked! Thank you.
add_filter( 'generate_blog_columns','db_tax_archive_column_count' );
function tu_portfolio_columns( $columns ) {
if ( is_category() || is_tag() ) {
return true;
}
return $columns;
}
add_filter( 'generate_blog_get_column_count','db_tax_archive_column_count' );
function db_tax_archive_column_count( $count ) {
if ( is_category() || is_tag() ) {
return 33;
}
return $count;
}
No problem :)