Trovare la fine del loop in WordPress

Un modo semplice per individuare l’ultimo post in un loop di wordpress.


if (($wp_query->current_post +1) == ($wp_query->post_count)) {
echo 'Questo è l'ultimo Post';
}

if (($wp_query->current_post +1) != ($wp_query->post_count)) {
echo 'Questo non è l'ultimo Post';
}

Rispondi