Support » Fixing WordPress » Count pages in a post in index.php

  • Good day, everyone!

    I cannot guess how to get around this, so need help badly..

    The thing is: I cannot find a way of counting a post subpages (made by <–nextpage–> tag manually or via a pagination plugin) when showing a list of posts’ excerpts in “index.php”.
    In single.php it was simple: just “<?php global $numpages; echo $numpages; ?>” and it worked!
    index.php shows solely ‘1’ and no more than this…

    Help, please – my blog’s gonna consist of quite a portion of long posts and it’s badly needed to display an overal post pages count in index.php

Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael


    Forum Moderator

    how did you get your posts/excerpts?

    seems to work (with or without query_posts and) the ‘normal’ loop;
    or otherwise maybe you have to use setup_postdata($post); to get wordpress to calculate $numpages

    After some more digging I’ve found that it is a “nextpage” plugin that adds a filter to “the_posts” and that plugin splits a post’s contents into pages, but it seems to work only at single.php. And even if I use “the_content” instead of “the_excerpt” in index.php, it still doesn’t do pagination.
    Could it be that “the_posts” filter works only with single.php?
    Maybe there is a possibility to hook such a filter to “the_excerpt” and break each post there in order to properly set $numpage, but still display only excerpt…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Count pages in a post in index.php’ is closed to new replies.