- This topic has 14 replies, 2 voices, and was last updated 3 years, 4 months ago by David.
-
AuthorPosts
-
November 26, 2020 at 12:05 am #1548636Alexandra
Hey guys!
I have a small issue with my shop archives (please see here: https://alex.bandiwork.dev/shop)
They don’t go fullwidth. I have inspected the page and I can see I gave grid-33 on .generate-columns, but I don’t know why and how to get rid of it.
Can you help, please?
Thank you so much!November 26, 2020 at 3:36 am #1549237DavidStaffCustomer SupportHi there,
thats very peculiar …. can you check first for plugin conflicts by temporarily disabling all plugins apart from GPP and Woocommerce.
November 26, 2020 at 6:07 am #1549513AlexandraHi, David!
Yes, I have disabled all plugins except for GP premium and Woo, but it’s the same π
Cleared cache too…
Is there anything else that could be done to fix the issue?
Thank you so much!November 26, 2020 at 7:19 am #1549893DavidStaffCustomer SupportDo you have any custom functions or a child theme installed or made any other edits to the theme?
November 26, 2020 at 10:23 am #1550323AlexandraOh, gosh! I feel so silly now!
Yes! With your help, I have figured out the issue is coming from this function I had added:add_filter( 'generate_blog_columns', function( $columns ) { $targets = array( 'articole-diverse', 'siguranta-pe-munte', ); if ( is_archive( $targets ) ) { return true; } return $columns; } );
I added this because I need columns on category archives for the custom post type called “articole” (siguranta-pe-munte & articole-diverse are categories for this custom post type).
Is there a way I can rewrite this function so that I can still have columns on these archives (sample CPT category archive page) without affecting shop product archives?
Thanks so much for this!
November 27, 2020 at 2:31 am #1551531DavidStaffCustomer SupportGood find π
Try this snippet instead:add_filter( 'generate_blog_columns','db_cpt_columns' ); function db_cpt_columns( $columns ) { if ( is_post_type_archive( array( 'articole-diverse', 'siguranta-pe-munte' )) { return true; } return $columns; }
The main difference is the conditional tag:
is_post_type_archive
November 27, 2020 at 5:59 am #1551973AlexandraHi, David!
I tried the snipped, but unfortunately, it doesn’t solve my problem. I think it is intended for CPT archives, not for CPT category archives.
Sample CPT archive – it works, I have columns
Sample CPT category archive – it doesn’t workIs there another function I could use in order to have columns on CPT category archives?
Thank you!November 27, 2020 at 7:24 am #1552551DavidStaffCustomer SupportQuestion – is there any other places that columns should be applied ? Then we can try and cover them all in one go.
November 27, 2020 at 11:26 am #1553226AlexandraYes, I actually want columns on all archives.
November 28, 2020 at 9:25 am #1555188DavidStaffCustomer SupportHave you enabled Columns in Customizer > Layout > Blog ? This would apply to all Post archives?
You would only then need the function provided here to set them for the CPT:https://generatepress.com/forums/topic/issue-with-woocommerce-shop-archives-grid-33/#post-1551531
November 28, 2020 at 10:19 am #1555267AlexandraYes, I have Columns enabled in the Customizer and I also placed that function, but I only have columns on post archives and CPT archives, not CPT category archives.
Please see my message above for CPT archive versus CPT category achieve.
How can I have columns also on CPT category archives?November 29, 2020 at 3:43 am #1556129DavidStaffCustomer SupportTry this:
add_filter( 'generate_blog_columns','db_cpt_columns' ); function db_cpt_columns( $columns ) { if ( is_post_type_archive( array( 'articole-diverse', 'siguranta-pe-munte' ) || is_tax() ) { return true; } return $columns; }
November 29, 2020 at 6:21 am #1556328AlexandraUnfortunately, it doesn’t work π
November 29, 2020 at 6:44 am #1556347AlexandraI have finally figured it out!! π
This solved everything:
add_filter( 'generate_blog_columns','db_cpt_columns' ); function db_cpt_columns( $columns ) { if ( is_post_type_archive( array( 'jocuri', 'articole', 'review-uri' ) ) || is_category( ) || is_tag( ) ) { return true; } return $columns; }
In the array I had to include all my custom post types.
I tried many alternatives, but this is the only one that enabled me to have columns on post archives, CPT archives and CPT categogy and tags archives without messing with my product archives. Hope this helps anyone facing the same issues πNovember 29, 2020 at 6:45 am #1556348DavidStaffCustomer SupportAah – its not a Custom Taxonomy!
Glad you found the answer π
-
AuthorPosts
- You must be logged in to reply to this topic.