Not able to fix common Woocommerce Product Loop Layout Problem
-
Hey!
Ok so I’ve seen this problem on other threads, but the common fix hasn’t worked for me. The product list layout / loop layout is wonky only on certain pages.For instance it lays out fine on https://talltique.com/product-category/plus-sizes/ but not on https://talltique.com/?s=basic&post_type=product&type_aws=true.
Will you help? Below is my code in content-product.php. I tried commenting out and deleting the woocommerce_loop code, but it makes all products disappear completely.
Other interesting note: On the pages where the layout messes up, the third product block in a given row will be outside the usual div.row (div with a class of row). On the pages where it works fine, all product blocks are within the div.row.
Thanks!
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly global $product, $woocommerce_loop,$wp_query; // Store loop count we're currently on if ( empty( $woocommerce_loop['loop'] ) ) $woocommerce_loop['loop'] = 0; // Store column count for displaying the grid $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 3 ); // Ensure visibility if ( ! $product || ! $product->is_visible() ) return; // Increase loop count $woocommerce_loop['loop']++; /* // Extra post classes $classes = ''; if ( 0 == ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] || 1 == $woocommerce_loop['columns'] ) $classes = 'first'; if ( 0 == $woocommerce_loop['loop'] % $woocommerce_loop['columns'] ) $classes = 'last'; */ $columns = 12/$woocommerce_loop['columns']; ?> <?php if( $woocommerce_loop['loop']%$woocommerce_loop['columns'] == 1 ) { ?> <div class="row"> <?php } ?> <div <?php post_class( 'shopcol '.$classes.' col-lg-'.$columns.' col-md-'.$columns.' col-sm-'.$columns.' col-xs-12' ); ?>> <?php wc_get_template_part( 'content', 'product-inner' ); ?> </div> <?php if( $woocommerce_loop['loop']%$woocommerce_loop['columns'] == 0 || $woocommerce_loop['loop'] == $wp_query->found_posts ) { ?> </div> <?php } ?>
- The topic ‘Not able to fix common Woocommerce Product Loop Layout Problem’ is closed to new replies.