WordPress.org

Ready to get started?Download WordPress

Forums

Count pages in a post in index.php (3 posts)

  1. LumaRay
    Member
    Posted 4 years ago #

    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

  2. alchymyth
    Forum Moderator
    Posted 4 years ago #

    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

  3. LumaRay
    Member
    Posted 4 years ago #

    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...

Topic Closed

This topic has been closed to new replies.

About this Topic