Get current page number of splitted article

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

Read More

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

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

Any idea? Thank you!

Related posts

Leave a Reply

2 comments

  1. 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 . '.';
    
  2. 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.