Columns For Category Archives
If you are looking to display posts that are in the category archive, there are 2 ways of achieving it.
You also take a look at the official GeneratePress Documentation as well.
Option 1
This is the easiest way to create columns but this will apply to your entire site.
1
Once you log in, go toAppearance > Customize.
2
Then go to Layout > Blog.
3
Scroll to the bottom and you’ll notice the option to enable Columns. Click to enable and wait for more options to appear.
4
You will be then presented with options to select the number of columns.
This is the easiest way to show categories in columns, but the drawback is that it converts all post archives to 2 columns.
If you would like the posts to display a single column format but wish to show category archives in multiple columns, this approach will not work.
Option 2
This is a good option if you want to maintain a single-column blog but want to show the Archives in columns only.
1
Go to Appearance > Theme Editor.
2
On the right-hand side, click on functions.php.
3
Copy the following code and paste it at the end.
Note
The following code will provide a 3 column layout for your archives. Filter return 33 means 33%, which will produce 3 columns.
2 columns – return 50
3 columns – return 33
4 columns – return 25
5 columns – return 20
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;
}
4
Once click on Update File to save the changes, you should see the columns on your archive page.
Final Results
Option 1 is the easiest way to show categories in columns, but the drawback is that it converts all post archives to columns.
If you would like the posts to display a single column format but wish to show category archives in multiple columns, this approach will not work.
Option 2 allows you to maintain the existing layout for the posts and adjust the columns on the Archive page for Categories.
there is an error in your code
thanks
Hi Murat,
Code has been updated. Sorry about that!
Hi!
What license is your site’s content being published under?
I would very much like to translate some guides into Portuguese.
Hi Frederico,
Feel free to translate it into Portuguese. Long as it’s not directly copied (layout, images, etc), I’m fine with it.
Link back to the website would be appreciated.