Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AdrianKuriata/2caffae276e6196e2c18a98304b8d1b6 to your computer and use it in GitHub Desktop.
Save AdrianKuriata/2caffae276e6196e2c18a98304b8d1b6 to your computer and use it in GitHub Desktop.
Detect the last post in the WordPress loop
<?php if (($wp_query->current_post +1) == ($wp_query->post_count)) {
echo 'This is the last post';
} ?>
<?php if (($wp_query->current_post +1) != ($wp_query->post_count)) {
echo 'This is the not the last post';
} ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment