Answers:
该WP_Query
对象包含一个max_num_pages
字段,其中包含帖子的页数。您可以将当前页码与此进行比较。(这是怎么get_next_posts_link()
做的。)
global $wp_query;
$current_page = $wp_query->get( 'paged' );
if ( ! $current_page ) {
$current_page = 1;
}
if ( $current_page == $wp_query->max_num_pages ) {
// You are on the last page
}
<?php if ( $wp_query->max_num_pages == get_query_var('paged') ) : ?> <div>TEXT</div><?php endif; ?>