Alex
Alex

Reputation: 1609

Getting paginated pages information from a Wordpress post

I'm seperating long posts using <!--nextpage--> but need to output user comments only on the last 'page' of a post. I can't find a way of counting the number of paginated pages and then outputting if page == last page.

Any help is appreciated

Upvotes: 0

Views: 450

Answers (1)

Pat
Pat

Reputation: 25675

You can check with $wp_query->query_vars['page']. On the first page, this value won't exists, whereas on the subsequent pages it will be set with the current page number.

$currentPage = isset($wp_query->query_vars['page']) ?  (int)$wp_query->query_vars['page'] : 1;

Upvotes: 1

Related Questions