WooCommerce Code snippets

Change the number of products displayed per page            


/** * Change number of products that are displayed per page (shop page)
*/
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options –> Reading
// Return the number of products you wanna show per page.
$cols = 9;
return $cols;
}


widget area on top of the category and shop pages



<?php // Create a new widget area called Product Category filter add_action( 'widgets_init', 'product_filter_widget_area' ); function product_filter_widget_area() { register_sidebar( array( 'id' => 'product_filter_sort', 'name' => __( 'Product filter widgets', 'rentattire' ), 'description' => __( 'Here goes your filter items', 'rentattire' ), 'before_widget' => '<div class="product-category-dropdown">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>' ) ); } // Add this widget area on top of the category and shop pages add_action( 'woocommerce_before_shop_loop','add_widget_area' ); // Hook it after headline and before loop function add_widget_area() { if ( is_active_sidebar( 'product_filter_sort' ) ) { dynamic_sidebar( 'product_filter_sort' ); } }


WooCommerce: How to Shorten Product Titles


// Note: this is simple CSS that can be placed in your custom.css file // This CSS also adds 3 dots ... at the end of each product title .woocommerce ul.products li.product h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }




































Comments