Implementing a general Table of Content across single paginated post pages

Just inspect the current post content for <!--nextpage-->:

function wpse_check_multi_page()
{
    $num_pages    = substr_count(
        $GLOBALS['post']->post_content,
        '<!--nextpage-->'
    ) + 1;
    $current_page = get_query_var( 'page' );
    return array ( $num_pages, $current_page );
}

On page 2 of 3 that returns:

Array
(
    [0] => 3
    [1] => 2
)

On an unpaged post it returns:

Array
(
    [0] => 1
    [1] => 0
)

Leave a Comment