-
George
I have two CPTs,
testimonials
andportfolio-new
. I have applied some different blog settings for their archives.// Portfolio and Testimonial archives add_filter( 'generate_blog_get_column_count','gm_custom_column_count' ); function gm_custom_column_count( $count ) { if ( is_post_type_archive( 'testimonial' ) || is_post_type_archive( 'portfolio-new' ) ) { return 33; } return $count; } add_filter( 'generate_blog_masonry','gm_testimonial_masonry' ); function gm_testimonial_masonry( $masonry ) { if ( is_post_type_archive( 'testimonial' ) ) { return 'true'; } return $masonry; } add_filter( 'option_generate_blog_settings', 'gm_custom_featured_column_page_settings' ); function gm_custom_featured_column_page_settings( $options ) { if ( is_post_type_archive( 'testimonial' ) || is_post_type_archive( 'portfolio-new' ) ) { $options['featured_column'] = false; } return $options; }
The both have a content template assigned, a separate one for each. I only see the
testimonial
archive in columns, though, theportfolio-new
displays one post below the other, no columns. I have cleared permalinks, no cache on the site, it’s a local install.What could be the issue?
-
George
Update: if I include conditional for the
portfolio-new
CPT for the masonry filter, it seems to work, columns are displayed but I obviously don’t want masonry layout for theportfolio-new
CPT.add_filter( 'generate_blog_masonry','gm_custom_masonry' ); function gm_custom_masonry( $masonry ) { if ( is_post_type_archive( 'testimonial' ) || is_post_type_archive( 'portfolio-new' ) ) { return 'true'; } return $masonry; }
-
Hi George,
For columns to work, you need to enable the columns first before setting columns number:
https://docs.generatepress.com/article/option_generate_blog_settings/#options-%E2%80%98column_layout%E2%80%99 -
George
It’s already set in the blog settings, I don’t think I need to set it again. Anyway, I tried the following, no change.
add_filter( 'generate_blog_get_column_count','gm_custom_column_count' ); function gm_custom_column_count( $count ) { if ( is_post_type_archive( 'testimonial' ) || is_post_type_archive( 'portfolio-new' ) ) { return 33; } return $count; } add_filter( 'option_generate_blog_settings', 'gm_custom_column_page_settings' ); function gm_custom_column_page_settings( $options ) { if ( is_post_type_archive( 'testimonial' ) || is_post_type_archive( 'portfolio-new' ) ) { $options['column_layout'] = true; $options['featured_column'] = false; } return $options; } add_filter( 'generate_blog_masonry','gm_testimonial_masonry' ); function gm_testimonial_masonry( $masonry ) { if ( is_post_type_archive( 'testimonial' ) ) { return 'true'; } return $masonry; }
As I said, columns are displayed for the
testimonial
CPT. -
I need to see your site’s backend.
-
George
See attached. Blog filters are towards the bottom. Archives can be accessed from the top.
-
George
Your solution here seems to be working. Not sure why it works for the testimonials, though, since I haven’t applied the
generate_blog_columns
filter for thetestimonial
CPT. -
So it means the page doesn’t meet the condition of
is_post_type_archive('portfolio-new')
.I guess you have to use this condition in this case:
'portfolio-new' === get_post_type() && ! is_singular()
-
George
Both CPTs should not have been set to display columns since columns have been set from the Customizer and columns should display by default on their archives. I have not set the columns to appear for the
testimonial
CPT in any other place but I get columns for it. For theportfolio-new
CPT, I had to use thegenerate_blog_columns
filter in order to get columns. I shouldn’t need to do that, that’s what I mean. -
Both CPTs should not have been set to display columns since columns have been set from the Customizer and columns should display by default on their archives.
GP does not know about the CPTs, you need to use the filter to tell it.
So if you remove all those filters, the testimonial archive still gets columns?
-
George
No, it doesn’t but it does when the
generate_blog_masonry
filter for that CPT is used! Very strange… -
George
Ok, I think when masonry filter is used to enable masonry, columns seems to get applied automatically which makes sense, I guess.
Thanks for looking into it!
- You must be logged in to reply to this topic.