[resolved] How to get post page number? (5 posts)

  1. Anna
    Posted 5 years ago #

    Hi all!

    I was working on a project last night and I found that I needed to paginate a post and have this format of navigation:

    << Page 1 / Total 6 >>

    Where "<<" and ">>" are arrows linking to the next and previous pages of the post.

    I've managed to figure out how to insert text in between the "<<" and ">>" but is there a way for me to get/echo the current post page number and the total number of pages for that post?

    Much thanks for any help!

  2. ClaytonJames
    Posted 5 years ago #

    I'm not sure that this is exactly what you are after, but it may be a jumping off point:

    "Displays page-links for paginated posts (i.e. includes the <!--nextpage--> Quicktag one or more times). This works in much the same way as link_pages(), the difference being that arguments are given in query string format. This tag must be within The_Loop. "

    Function Reference/wp link pages

    Then there is also (same thing - just using the quicktag in your post ) paginating a post by inserting <!--nextpage--> at the desired page break points in your post while editing in the html editor. That results in pagination in a post that looks like:

    Pages: 1 2 3

    [EDIT] this might be a secondary issue/consideration, and includes the styling you suggest using &raquo and &laquo;

    Styling Page-Links

  3. Anna
    Posted 5 years ago #

    Thanks for taking the time to respond!

    I am using wp_link_pages right now to display the "<<" and ">>".

    What I am asking is if it is possible to display the current page number and the total number of pages through some PHP snippet or some sort?

    I don't mean the available options of "1 2 3 4 5 6" or "Page 1, Page 2, Page 3, Page 4, Page 5, Page 6" or "Page 1, 2, 3, 4, 5, 6" or any variations available through styling of the wp_link_pages function because I don't want to list all the pages. Only the current page you're at and the total number of pages.

    Sorry if I didn't explain it as properly as I would like.

  4. ClaytonJames
    Posted 5 years ago #

    No, you were pretty clear. I'm sorry for not reading it a little more carefully. :-)

    This is an older post, but it seems to be very similar to what you might be after. There is a solution posted there, but the version then was wordpress 2.8.6. Perhaps that won't matter.

    Styling Page-Links look like: < 1/3 >

    This one is a little newer, and appears to hold a very different solution.

    Get current page number for paginated posts"
    "I'm trying to get the current page and the total number of pages for paginated posts"

    Good luck to you!

  5. Anna
    Posted 5 years ago #

    Ah, those look perfect! I will test them in just a few.

    Thank you very much!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.