Skip to content

Commit

Permalink
reset loop on loop_end
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Jul 19, 2012
1 parent 4856636 commit a239922
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 1 addition & 4 deletions classes/class-wc-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ function __construct() {
* Hook into pre_get_posts to do the main product query
*/
function pre_get_posts( $q ) {
global $woocommerce, $woocommerce_loop;

// Reset loop/columns globals when starting a new loop
$woocommerce_loop['loop'] = $woocommerce_loop['column'] = '';
global $woocommerce;

// We only want to affect the main query
if ( ! $q->is_main_query() )
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==

= 1.6.2 - 19/07/2012 =
* Tweak - woocommerce_reset_loop() on loop_end to reset columns and index
* Fix - Product categories shortcode loop

= 1.6.1 - 19/07/2012 =
Expand Down
1 change: 1 addition & 0 deletions woocommerce-hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );

/* Products Loop */
add_filter( 'loop_end', 'woocommerce_reset_loop' );
add_action( 'woocommerce_before_shop_loop', 'woocommerce_show_messages', 10 );
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
Expand Down
7 changes: 7 additions & 0 deletions woocommerce-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ function woocommerce_show_product_loop_sale_flash() {
woocommerce_get_template( 'loop/sale-flash.php' );
}
}
if ( ! function_exists( 'woocommerce_reset_loop' ) ) {
function woocommerce_reset_loop() {
global $woocommerce_loop;
// Reset loop/columns globals when starting a new loop
$woocommerce_loop['loop'] = $woocommerce_loop['column'] = '';
}
}

/**
* WooCommerce Product Thumbnail
Expand Down

0 comments on commit a239922

Please sign in to comment.