Site logo

Archived topic

CPT > Changing the number of columns

3 replies · Started by Brenden on September 8, 2021

Viewing posts 1–4 of 4

I followed the instructions provided here - https://docs.generatepress.com/article/using-columns-in-the-blog/#changing-the-number-of-columns, but I can't get it to work. Here is my code.

add_filter( 'option_generate_blog_settings', function( $settings ) {
    if ( is_post_type_archive( 'priorities' ) ) {
        $settings['columns'] = '33';
    }

    return $settings;
} );

While troubleshooting, I also tried this code below which did work, but I don't want to use the Customizer setting because I need the CPT to be different from the Posts.

add_filter( 'generate_blog_columns','tu_portfolio_columns' );
function tu_portfolio_columns( $columns ) {
    if ( is_post_type_archive( 'priorities' ) ) {
        return true;
    }

    return $columns;
}

Hi there,

Not sure if I fully understand.

You will need both of those snippets in order to apply columns to CPT.

The code should not change what you have in the customizer though?

Let me know what I'm missing here.

Ah, that makes sense. My problem was that I was only trying one of those snippets at a time, but not both at the same time. From the documentation it was not clear to me that I needed to use both of those snippets together.

Everything is working as desired now though. Thank you!

No problem :)

This archived topic is closed to new replies.