Okay
  Public Ticket #3016770
number of product columns for category
Closed

Comments

  •  3
    natah started the conversation

    Hi!

    is there a way to show different number of columns for a category ?

    I tried the code to my functions.php but did not work

    /*  Set product columns for specific category */
        add_filter('loop_shop_columns', 'loop_columns');     if (!function_exists('loop_columns')) {        function loop_columns() {            if ( is_product_category('a')) {                return 3;            } else if ( is_product_category('c')) {                return 2;            }else{                return 4;               }        }    }

    can you please advice me how to fix that ?

    thanks in advance

  •  1,877
    Judith replied

    Hi Natah,

    Thanks for keeping in touch.

    You can change this at Salient Options panel > WooCommerce > General

    9027999350.png

    Thanks

  •  3
    natah replied

    yes i saw this but I want to have for category product A  4 columns

    and for category B 3 columns

    please read the code

    why it is not working?

  •  1,877
    Judith replied

    Hi Natah,

    Please allow me to escalate this to the developer to respond further.

    Thanks.

  •  1,070
    ThemeNectar replied

    Hey natah,

    The Salient theme options for column sizing overrides the default WooCommerce column number. If you wish to implement unique sizing per category, you would need to do so via the following method:

    add_action('wp','salient_child_woo_cat_column_sizing');
    function salient_child_woo_cat_column_sizing() {
      if( is_product_category('your-category') ) {
        Redux::setOption('salient_redux', 'product_desktop_cols', '3');
        Redux::setOption('salient_redux', 'product_desktop_small_cols', '3');
      } else {
        Redux::setOption('salient_redux', 'product_desktop_cols', '4');
        Redux::setOption('salient_redux', 'product_desktop_small_cols', '4');
      }
      
    }
    

    Kind regards,

  •  3
    natah replied

    thank you for your reply but it is not working.

    I have set salient options / woocommerce / general as default

    6657144829.png

    and I have add the following code to my functions.php


    // Change the Number of Columns Displayed Per Category
    add_action('wp','salient_child_woo_cat_column_sizing');
        function salient_child_woo_cat_column_sizing() {
        if( is_product_category('organic-wines') )    
        {
            Redux::setOption('salient_redux', 'product_desktop_cols', '6');
            Redux::setOption('salient_redux', 'product_desktop_small_cols', '6');
        }     else     {
            Redux::setOption('salient_redux', 'product_desktop_cols', '5');
            Redux::setOption('salient_redux', 'product_desktop_small_cols', '5');
        }  
    }

    i have also tried    if( has_term( 'organic-wines', 'product_cat' ) )

    but it always shows 4 columns for all categories

    can you please find why your code is not override the default ?

    *I also tried with empty or other number at salient settings - it always get the number of salient options

    thanks in advance
  •  8,839
    Tahir replied

    Hey Again,

    Could you allow us to log in to your website backend dashboard so we can check on this for you more?. We are gonna need the username and password of admin user as well as the login url.

    Thanks 


    ThemeNectar Support Team 

  •  3
    natah replied

    it is working!

    I had changed the theme to Salient and forgot to change it back to Salient Child....

    sorry :D

    thank you for your help