Last product/category in loop
-
Hello there,
https://tp4x4.v2webdesign.co.uk/products/
I’m wondering if it possible to find out when the category/product loop is the last.
I’m in the process of building a customer template and to organise the products I am using a grid.
This is in files: content-product-cat.php & content-product.php
<?php if ($woocommerce_loop['loop']&1){ ?> <div class="row product-grid-row"> <?php }?> <div class="product-category product large-6 small-12 columns"> content stuff is here </div> </div> <?php if ($woocommerce_loop['loop']&2) { ?></div><?php } ?>
This code opens the .product-grid-row div for each odd number and closes it for each even number, creating 2 products per row.
The problem is when the last product is an odd number or there is an odd number if products/categories.
If there is a way to determine the number of categories/products in that loop I can simply use that variable:
if ($lastinloop) echo "</div>";
Any help would be greatly appreciated.
Thanks,
Oli
- The topic ‘Last product/category in loop’ is closed to new replies.