Skip to content

Instantly share code, notes, and snippets.

@Farmatique
Created August 16, 2019 15:24
Show Gist options
  • Save Farmatique/c7e90f2107de21663e27673f125cbf58 to your computer and use it in GitHub Desktop.
Save Farmatique/c7e90f2107de21663e27673f125cbf58 to your computer and use it in GitHub Desktop.
Get index within Wordpress posts loop
<?php $index = 0; while (have_posts()) : the_post(); ?>
<?php get_template_part('partials/content', get_post_type() != 'post' ? get_post_type() : get_post_format()); ?>
<div class="temp-index"><?=$index;?></div>
<?php $index++;endwhile; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment