How to add classes using php?

For example, 4 units
824815a7eb6d447ebe1ea2d1208984bb.jpg

Or just numbered from 1 to 4
July 8th 19 at 11:24
1 answer
July 8th 19 at 11:26
Solution
Something like that. If in a loop.
<?php
$counter = 0;
while(have_posts()) :
 $class = 'class-' . $counter++; ?>
 <div class="<?php echo $class ?>">
 <?php the_content() ?>
</div>
<?php endwhile;</code-->
FROM THE SOUL) THANK YOU - bernita_Johnston commented on July 8th 19 at 11:29

Find more questions by tags WordPress