您可以非常简单地循环幻灯片:
$prev_index = ( $loop->current_post == 0 ) ? count( $loop->posts ) - 1 : $loop->current_post - 1;
$next_index = ( $loop->current_post == count( $loop->posts ) - 1 ) ? 0 : $loop->current_post + 1;
$prev_post = $loop->posts[ $prev_index ];
$next_post = $loop->posts[ $next_index ];
echo $next_post->post_title;
echo $next_post->post_title;
如果当前帖子是第一篇帖子,则取上一篇帖子的最后一篇帖子;如果当前帖子是最后一篇帖子,则取下一篇帖子的第一篇帖子。