Skip to content

Instantly share code, notes, and snippets.

@growdev
Last active December 15, 2015 05:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save growdev/5210074 to your computer and use it in GitHub Desktop.
Save growdev/5210074 to your computer and use it in GitHub Desktop.
WooCommerce 2.0.4 - Change number of columns of thumbnails for Up Sells on product page.
<?php
// first remove the action defined in woocommerce-hooks.php
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
// modeled off of the woocommerce_upsell_display() function in woocommerce-template.php
// change $columns to desired number of columns
function my_woocommerce_upsell_display( $posts_per_page = '-1', $columns = 5, $orderby = 'rand' ) {
woocommerce_get_template( 'single-product/up-sells.php', array(
'posts_per_page' => $posts_per_page,
'orderby' => $orderby,
'columns' => $columns
) );
}
// re-add the action for display
add_action( 'woocommerce_after_single_product_summary', 'my_woocommerce_upsell_display', 15 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment