Let’s say you have taken over a website for a podcast. Each time a episode of this podcast is produced, a WordPress post is published that provides information about that episode. There are over 500 episodes to date.
You’ve been tasked with displaying the podcast episode number in the podcast archives, and you’d rather not manually add custom meta for each of the 500+ episodes.
We’ll show you how to:
- Get the total count of published posts in a certain post type.
- Count backwards as you iterate through the WordPress loop.
- Adjust the episode number accordingly through paged archives.
- BONUS: Make it work with Jetpack Infinite Scroll too.
This is the exact same effect I use on the Themetry website to give visitors a visual idea of what number tutorial they’re on in the index.