I'm trying to return the number of products in a loop and output this before the loop. The below always returns 0, so is there a way that I can delay outputting this until after it has finished the loop?
if( $post_objects ):
$prodcount = 0;
?>
<h1>There are <?php echo $prodcount ?> items</h2>
<?php foreach( $post_objects as $post_object): ?>
<p>something</p>
<?php $prodcount++ ?>
<?php endforeach; ?>
<?php endif; ?>
Aucun commentaire:
Enregistrer un commentaire