Different amount of Woocommerce columns on home page


I’m trying to set different number of columns on homepage. Theme has an option to set in through theme panel, so i found a function responsible for this in files.

I’ve tried already shortcodes on home page and it doesn’t want to work (it’s showing even 2 instead of 3 or 4). I think theme is blocking shortcodes.

My idea was to us if condition and run do function only on pages which are not a home page and add second function to set 4 columns only on homepage

This a code from template woocomerce files:

add_filter('loop_shop_columns', 'cardealer_loop_columns');

if (!function_exists('cardealer_loop_columns')) {   
    function cardealer_loop_columns() {
        global $car_dealer_options;        
        $pro_col_sel = 4;
        if(isset($car_dealer_options['wc_product_list_column']) && !empty($car_dealer_options['wc_product_list_column'])){
            $pro_col_sel = $car_dealer_options['wc_product_list_column'];    
        return $pro_col_sel; // 3 products per row

function cardealer_loop_columns_class(){
    $column = cardealer_loop_columns();
    echo 'columns-'.$column;    

I was trying to use many options and always i’m ending up with the same result as with shortocodes – 2 columns on hompage with 3 columns styling and 3 columns on the other pages. My aim is to set 4 columns on home page (with 4 columns style/class) and three columns on other pages (with 3 columns style/class)

, , Patryk 8 months 0 Answers 40 views 0

Leave an answer