• Hi,

    I am trying to change the number of product catergory columns that appear in Woocommerce, from 3 to 4. But I am not having much luck.

    I have tried to create a child theme for storefront, to no avail. For some reason this is not working. So I’m at this point even willing to change the functions.php code for the parent theme (storefront). But I don’t know what code I need to add to change the number of catergory columns on my shop page?

    (What ever code I use, I would need it to be responsive.)

    If anyone can help me, this would be much appreciated!

    Thanks,

    Zoe.

Viewing 3 replies - 1 through 3 (of 3 total)
  • in functions.php of the child theme, add:

    add_filter( 'storefront_loop_columns', function() { return 4; } ); //change shop colunns//

    in style.css of the child theme, add (for example):

    /*adjustment for 4 shop columns*/
    @media (min-width:768px){
    	.site-main ul.products li.product {
    		width: 22%;
    		margin-right:4%;
    	}
    }
    Thread Starter happygolucky35

    (@happygolucky35)

    Hi Michael,

    thanks for taking the time to reply.

    I’ve tried the above code (I added the PHP first to my child theme file), but an error came up and my site was no longer accessible.

    The error message said:

    Parse error: syntax error, unexpected ‘?>’

    Just to confirm, before I added the above code, my child theme functions file was empty except for the opening and closing tags:

    <?php

    ?>

    I hope someone can help me with this, because I’ve spent two days now trying to resolve this issue ??

    if you start with an empty functions.php file in the child theme, the total added code (the total code in the file) should be:

    <?php
    add_filter( 'storefront_loop_columns', function() { return 4; } ); //change shop colunns//

    there is no need to add the closing php tag:

    ?>

    make sure to have absolutely no characters before the first line with the opening tag
    <?php

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to change number of columns in Woocommerce?’ is closed to new replies.