How to get current page number in a multipage post
-
Hi,
I’m working on my first plugin. It’s actually shortcode that I want to add that each post that has more then one page (multipage postings) by splitting the post with the !–nextpage– directive.
So far the shortcode is working but does nothing more that creating a simple list. The list must also contain a link the the appropriate page. Now I could simply do the following…
$menu_items = ""; $page_url = get_permalink(); foreach ($menu_titles as $key=>$title) { $page = $key + 1; $menu_items .= "<li><a href=\"{$page_url}\">{$title}</a></li>\n"; }
…and add a “/{$page}” when $page > 1. But currently I have no idea how to figure out on which page of the post I am so that I can skip rendering that link and/or add a different css-class eg.
Is it possible to get the current page of the posting in an elegant wordpress way or do I need to evaluate the current url for that (which i do no prefer).
Regards
Sjoerd
- The topic ‘How to get current page number in a multipage post’ is closed to new replies.