How to add count to woocommerce loop

I need to add a counter to implement a unique id for each item in a Woocommerce product loop. I would normally do this in WordPress by adding something like before the loop starts and then for each item. However the Woocommerce loop is broken up and spread across several files and this has thrown me a little.

I have found the ‘loop-start’ file which contains the opening of the loop’s ul and the content-product file which contains the li plus all the various hooks. But I cannot for the life of me work out how the content-product file is being called.

Adding the snippets of code to content-product simply creates a repeated result of one, which is what I would expect as they are both inside the repeating element. If I place the first part in loop-start I get no result, which I assume is because it is in a different file.

So how would I get the count to work. I’m thinking I would need to add something within my functions file, but I’m not clear what.

Read more here:: How to add count to woocommerce loop

Leave a Reply

Your email address will not be published. Required fields are marked *