[Resolved] Issue with Woocommerce shop archives (grid-33)

Home Forums Support Issue with Woocommerce shop archives (grid-33)

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #1548636
    Alexandra

    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!

    #1549237
    David
    Staff
    Customer Support

    Hi there,

    thats very peculiar …. can you check first for plugin conflicts by temporarily disabling all plugins apart from GPP and Woocommerce.

    #1549513
    Alexandra

    Hi, 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!

    #1549893
    David
    Staff
    Customer Support

    Do you have any custom functions or a child theme installed or made any other edits to the theme?

    #1550323
    Alexandra

    Oh, 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!

    #1551531
    David
    Staff
    Customer Support

    Good 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

    #1551973
    Alexandra

    Hi, 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 work

    Is there another function I could use in order to have columns on CPT category archives?
    Thank you!

    #1552551
    David
    Staff
    Customer Support

    Question – is there any other places that columns should be applied ? Then we can try and cover them all in one go.

    #1553226
    Alexandra

    Yes, I actually want columns on all archives.

    #1555188
    David
    Staff
    Customer Support

    Have 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

    #1555267
    Alexandra

    Yes, 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?

    #1556129
    David
    Staff
    Customer Support

    Try 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;
    }
    #1556328
    Alexandra

    Unfortunately, it doesn’t work πŸ™

    #1556347
    Alexandra

    I 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 πŸ™‚

    #1556348
    David
    Staff
    Customer Support

    Aah – its not a Custom Taxonomy!

    Glad you found the answer πŸ™‚

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