Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1266646
    wai
    Participant

    I was given this code earlier to change the number of columns display for this category archive:

    add_filter('x_option_x_woocommerce_shop_columns', 'x_term_column');
    
    function x_term_column ( $cols ) {
    
    if ( is_product_category() && get_queried_object()->term_id == 329 ) {
    
    return 4;
    
    }
    
    return $cols;
    
    }

    I also want to display 4 columns on my other category archives. Like here: https://www.mays.net.au/products/jewellery/pendant/
    and
    https://www.mays.net.au/products/jewellery/necklace/
    But I have no idea how to modify this code.

    Please help!

    #1266652
    Paul R
    Moderator

    Hi,

    Please update your code to this.

    
    add_filter('x_option_x_woocommerce_shop_columns', 'x_term_column');
    
    function x_term_column ( $cols ) {
    
    if ( is_product_category() && get_queried_object()->term_id == 329 && !is_product_category('pendant') && !is_product_category('necklace') ) {
    
    return 4;
    
    }
    
    return $cols;
    
    }
    

    Hope that helps.

    #1266664
    wai
    Participant

    I updated the code. It didn’t do anything.

    #1266665
    wai
    Participant
    This reply has been marked as private.
    #1266672
    Christopher
    Moderator

    Hi there,

    Please change number of Shop Columns under Customize -> Woocommerce.

    Hope it helps.

    #1266677
    wai
    Participant

    I only want the sub-categories archives to have 4 columns not all. Please review the code above.

    #1266695
    Paul R
    Moderator

    Hi,

    You need to set the default column in Shop Columns under Customize -> Woocommerce.

    Then you can add the categories you wanted to have 4 columns in your filter code.

    eg.

    
    
    add_filter('x_option_x_woocommerce_shop_columns', 'x_term_column');
    
    function x_term_column ( $cols ) {
    
    if ( is_product_category() && (get_queried_object()->term_id == 329 || get_queried_object()->term_id == 642 )) {
    
        return 4;
    
    }
    
    return $cols;
    
    }
    

    It will set these categories to 4 columns

    https://www.mays.net.au/products/jewellery/
    https://www.mays.net.au/products/gemstones/

    Hope that helps.

    #1266706
    wai
    Participant

    That code did the job, thanks! 🙂

    #1266719
    Darshana
    Moderator

    Glad we were able to help 🙂

  • <script> jQuery(function($){ $("#no-reply-1266646 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>