Using Columns in the Blog

Note: These options require the Blog add-on in GP Premium.

We can enable columns in our blog by going to Customize > Blog > Columns.

These settings apply to the post post type by default, and will display on your blog index, archives, tags and categories.

If you have masonry enabled, these options will be ignored.

  • Column Layout – enable or disable columns.
  • Columns – the number of columns to display.
  • First post full width – choose whether the latest post is full width (featured)

Adding columns to your custom post type

By default, columns only apply to the post post type. However, you can add columns to your custom post type using the filter:

add_filter( 'generate_blog_columns','tu_portfolio_columns' );
function tu_portfolio_columns( $columns )
{
    if ( is_post_type_archive( 'portfolio' ) ) :
        return true;
    endif;

    return $columns;
}

You can use this filter to enable or disable columns under any conditions you need by using the WordPress conditional tags.

Learn how to add PHP here.

Changing the number of columns

In some cases, you might want a different number of columns on certain custom post types, categories etc.. We can use a filter for this as well.

For example, if we want to change our column count on the search page:

add_filter( 'generate_blog_get_column_count','tu_search_column_count' );
function tu_search_column_count( $count )
{
    if ( is_search() )
        return 33;

    return $count;
}

33 means 33%, which is 3 columns.

50 would be 50%, 2 columns.

20 would be 20%, 5 columns.

And so on..

You can use this filter under any conditions you need by using the WordPress conditional tags.

Learn how to add PHP here.