GeneratePress

Customization Tips

Let's advance your theme's functionality.

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.

Appearance Customize v1

2

Then go to Layout > Blog.

Layout Blog v1

3

Scroll to the bottom and you’ll notice the option to enable Columns. Click to enable and wait for more options to appear.

Layout Columns v1

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.

Number of Columns v1

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.

Appearance Theme Editor v1

2

On the right-hand side, click on functions.php.

Functions PHP v1

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.

Function Save File v1

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.

2 Columns v1

Comments (4)

  1. Hi!

    What license is your site’s content being published under?
    I would very much like to translate some guides into Portuguese.

    Reply
    • 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.

      Reply

Leave a comment