Last active
April 7, 2020 17:56
-
-
Save helgatheviking/85e18c1cb46b7191951de69fbe4a004b to your computer and use it in GitHub Desktop.
Change number of columns in MNM grid layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change number of columns in grid layout | |
* @param int $columns | |
* @param obj $product | |
* @return int | |
*/ | |
function kia_change_mnm_columns( $columns, $product ) { | |
return 4; | |
} | |
add_filter( 'woocommerce_mnm_grid_layout_columns', 'kia_change_mnm_columns', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code appears to still work with TwentyTwenty. It adds a
columns-4
class to the<ul>
that determines the grid sizes, then afirst
class to the first item in the row and alast
class to the last item. Thewoocommerce/assets/css/woocommerce-layout.css
then handles all the layout.Especially important is the 0 margin on the
.last
item of the row. However, if your theme has overriddenwoocommerce-layout.css
stylesheet then the styles may not work. Specifically without it, you're almost guaranteed to get the alternating 4/5/4/5 situation as some rows will have the width for 4 and some for 5 depending on where the theme is putting the 0 margin item.Additionally, if your theme is interfering in the WooCommerce loop somehow or if your theme has a custom grid layout... it may also not work for those reasons.
If you have a license please submit a support ticket and while I can't support individual themes, I could probably at least diagnose the issue for you: https://woocommerce.com/my-account/create-a-ticket/