K
K
Karen Mnatsakanyan2016-12-14 14:46:12
WordPress
Karen Mnatsakanyan, 2016-12-14 14:46:12

Incrementing woocommerce files?

Hi all!
I need to start incrementing in the content-product.php file, that is, before the cycle
<?php $i = 1; ?>
In the cycle

<?php echo $i; ?>
<?php $i ++; ?>

how to implement it? I can't find the loop here.
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yanchevsky, 2016-12-14
@karjan

Hello.
Loop in archive-product.php file.
Surely there is some better way, but I think this option should also work:

<?php global $i; $i = 0; while ( have_posts() ) : the_post(); ?>
    <?php wc_get_template_part( 'content', 'product' ); ?>
<?php $i++; endwhile; // end of the loop. ?>

Well, and, accordingly, add to content-product.php
global $i; echo $i;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question