• Ifor multi page posts, I recently discovered a very helpful hack that allows having both next and prev text (which I replaced with arrows) and a list of linked pages in between the arrows. I would like to replace the linked pages with text that says (for example) “page 2 of 8”

    Does anyone know of a quick solution, or barring that, where the code for setting up the page links is so i can play with that? Any help appreciated, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    Take a look at the source for get_next_posts_link() in wp-includes/link-template.php. Note how the pagination data is stored in globals.

    I recently discovered a very helpful hack that allows having both next and prev text (which I replaced with arrows) and a list of linked pages in between the arrows

    start by linking to the source of that ‘hack’ to give anybody here a reference point to build on.

    in general, in a multi-page post (or page) – done with <!--nextpage--> – within the loop, the current page is the global variable $page and the total number is $numpages

    Thread Starter RobbFritz

    (@robbfritz)

    Here’s the link to the customization:
    https://www.velvetblues.com/web-development-blog/wordpress-number-next-previous-links-wp_link_pages/

    While adding the customization to the site I’m working on, I did figure out that the variables I want to use are the $page and $numpages – my question then is where in the template do I change out producing the string of page links with the “Page $page of $numpages” code.

    here’s an example page of what I’m working on:
    https://blog.insidebeautiful.com/?p=56&page=2

    I don’t see any easy way to integrate your idea into wp_link_pages() by just using filter functions;
    you possibly need to write your own function to replace wp_link_pages()

    btw: as reference, the core function wp_link_pages() is in /wp-includes/post-template.php from line 637

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Replace page links with "page x of y" for multi page posts’ is closed to new replies.