I am trying to find a way to get the current page number of an article that has been splitted into several pages with the use of:

<!-- nextpage -->

There is an example that can be found here: http://codex.wordpress.org/Conditional_Tags#Testing_for_paginated_Pages

But this doesn't work for me – it always returns 0:

$paged = $wp_query->get( 'paged' );
echo $paged;

Any idea? Thank you!

  • If one of the answers helps you, select it as the answer please.
    – hakre
    Jul 8, 2011 at 14:37

2 Answers 2


For multi-page posts:

  • The $page global variable returns the current page of a multi-page post.
  • The $numpages global variable returns the total number of pages in a multi-page post.

For paginated archive index pages:

  • The $paged global variable returns the current page number of a paginated archive index.

To use any of these variables, simply globalize them first:

global $page;

echo 'The current page number of this post is ' . $page . '.';

There you go:

$queryVars = $wp_query->query_vars;
    $pageNum = ($queryVars[page]);

    if($pageNum) { 
        echo "Page n&deg;" . $pageNum; 
    } else { 
        echo "Page n&deg;1";

Tested with wp 3.2 with basic permalinks and custom.

Edit: Didn't see Chip Bennett's answer wich is smaller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.