views:

19

answers:

1

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

+1  A: 

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;
Pat
Thanks for this, it's very nearly what I'm after. I can't see how to find out what the total number of paginated pages are though (in order to see if the current page is the last page). Tried looking for more info on query_vars[] but couldn't find anything that listed all subparts to it :(
Alex
Ah apologies - I misread the question. Take a look at this code in this guy's `paginate.txt` function: http://www.ericmmartin.com/pagination-function-for-wordpress/. Starting on line 49 is has a bit of code that might do the trick for you.
Pat
Haha, think you were closer the first time, I know how confusing this is though thanks to Wordpress's poor terminology. I tried using the link and it looks like that code just deals with pagination from a multiple posts point of view, instead of from a single post with multiple pages (<!--nextpage--> being used). Hope that makes sense :/
Alex
Heh, that's what I suspected, but after a bunch of googling, that's all I could come up with. I was just poking around the source code for `wp_link_pages` (http://core.trac.wordpress.org/browser/tags/3.0.1/wp-includes/post-template.php) and they have a `global $numpages` variable defined. I'm wondering if that would be available to you?
Pat
Perfect, thanks Pat :)Managed to use if($page == $numpages) for last page of a post, and if($page == 1) for first page. Thanks again
Alex