[Resolved] CPT Column Filter Breaking Layout >=3 columns

Home Forums Support [Resolved] CPT Column Filter Breaking Layout >=3 columns

Home Forums Support CPT Column Filter Breaking Layout >=3 columns

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #738654
    Kevin

    Hi there,

    On a brand new installation of WordPress, GeneratePress theme and GP Premium, I am using a filter to set the number of columns on a custom post type archive.

    https://docs.generatepress.com/article/using-columns-in-the-blog/#changing-the-number-of-columns

    add_filter( 'generate_blog_get_column_count','kpry_search_column_count' );
    function kpry_search_column_count( $count ) {
        if ( is_post_type_archive() ) {
            return 33;
        }
    
        return $count;
    }

    I am getting unexpected results when setting 3 or more columns:

    1. Only two columns per row
    2. Large spacing between columns

    I know the filter is working because each time I change it the layout changes – just not what I expect it to change to.

    Screenshots
    https://imgur.com/a/mPJWl6b

    Thank you.

    #738869
    Leo
    Staff
    Customer Support

    Hi there,

    Any chance you can link us to the site in question?

    You can edit the original topic and use the private URL field.

    Let me know πŸ™‚

    #739938
    Kevin

    Hi Leo,

    I have added the URL in the private URL field. I can provide WP and FTP credentials upon request.

    #740121
    Tom
    Lead Developer
    Lead Developer

    Can you try returning a string instead of a number?:

    add_filter( 'generate_blog_get_column_count','kpry_search_column_count' );
    function kpry_search_column_count( $count ) {
        if ( is_post_type_archive() ) {
            return '33';
        }
    
        return $count;
    }

    Let me know πŸ™‚

    #740305
    Kevin

    A string does not change the symptom. Thank you.

    #740855
    Tom
    Lead Developer
    Lead Developer

    Ah, looks like a bug.

    For now, you can do this instead:

    add_filter( 'option_generate_blog_settings', function( $settings ) {
        $settings['columns'] = '33';
    
        return $settings;
    } );
    #740901
    Kevin

    Thanks Tom. Great theme! Great support!

    #741682
    Tom
    Lead Developer
    Lead Developer

    Thanks! πŸ™‚

    #778690
    Kevin

    Hi Tom, I am wondering if this bug has been fixed and pushed out yet?

    I ask because the code you suggested resets the “global” column settings in the customizer, therefore affecting all archives:

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

    I’d love to use the filter but if the bug is still being resolved, is there another way I can conditionally use 3 column layout only on a custom post type archive?

    Thanks!

    #778778
    Tom
    Lead Developer
    Lead Developer

    It’s been fixed in GPP 1.8.

    For now, you can do this:

    add_filter( 'option_generate_blog_settings', function( $settings ) {
        if ( is_post_type_archive( 'team_member' ) ) {
            $settings['columns'] = '33';
        }
    
        return $settings;
    } );
    #779378
    Kevin

    Thanks Tom. You are awesome.

    #779627
    Tom
    Lead Developer
    Lead Developer

    Glad I could help πŸ™‚

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