Site logo

[Support request] Adjustment of column number in CPT archive applied to general post archive

Home Forums Support [Support request] Adjustment of column number in CPT archive applied to general post archive

Home Forums Support Adjustment of column number in CPT archive applied to general post archive

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2552933
    Jens

    I have used a code from the help forum to adjust the number of columns of a custom post types (“template”). This worked. I now see 4 columns in the respective archive. Unfortunately the number of columns in the general post archive (set to 3 in customizer in Generatepress theme) has also changed to 4. How can I ensure that the 4 columns is only applied to the CPT?

    add_filter( 'generate_blog_columns','tu_portfolio_columns' );
    function tu_portfolio_columns( $columns ) {
        if ( is_post_type_archive( 'template' ) ) {
            return true;
        }
    
        return $columns;
    }
    
    add_filter( 'generate_blog_get_column_count', function( $column_width ) {
        if ( is_archive ('template') ) {
            return '25';
        }
    
        return $column_width;
    } );

    Thanks in advance!

    #2553070
    David
    Staff
    Customer Support

    Hi there,

    thats odd, what if you use the is_post_type_archive( 'template' ) template tag in the second function ie.

    add_filter( 'generate_blog_get_column_count', function( $column_width ) {
        if ( is_post_type_archive( 'template' ) ) {
            return '25';
        }
    
        return $column_width;
    } );
    #2553162
    Jens

    Thanks a lot! That did the trick 🙂

    #2553342
    David
    Staff
    Customer Support

    Glad to hear that!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.