- This topic has 11 replies, 3 voices, and was last updated 5 years, 3 months ago by Tom.
-
AuthorPosts
-
November 25, 2018 at 9:13 am #738654Kevin
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:
- Only two columns per row
- 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/mPJWl6bThank you.
November 25, 2018 at 12:38 pm #738869LeoStaffCustomer SupportHi 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 π
November 26, 2018 at 7:21 am #739938KevinHi Leo,
I have added the URL in the private URL field. I can provide WP and FTP credentials upon request.
November 26, 2018 at 9:29 am #740121TomLead DeveloperLead DeveloperCan 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 π
November 26, 2018 at 11:23 am #740305KevinA string does not change the symptom. Thank you.
November 26, 2018 at 7:26 pm #740855TomLead DeveloperLead DeveloperAh, looks like a bug.
For now, you can do this instead:
add_filter( 'option_generate_blog_settings', function( $settings ) { $settings['columns'] = '33'; return $settings; } );
November 26, 2018 at 8:16 pm #740901KevinThanks Tom. Great theme! Great support!
November 27, 2018 at 8:51 am #741682TomLead DeveloperLead DeveloperThanks! π
January 10, 2019 at 1:50 pm #778690KevinHi 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!
January 10, 2019 at 4:46 pm #778778TomLead DeveloperLead DeveloperIt’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; } );
January 11, 2019 at 9:41 am #779378KevinThanks Tom. You are awesome.
January 11, 2019 at 6:12 pm #779627TomLead DeveloperLead DeveloperGlad I could help π
-
AuthorPosts
- You must be logged in to reply to this topic.