[wp-hackers] Access the total number of pages of a multipage post or page out of the loop
Aldo Latino
aldolat at gmail.com
Tue Apr 27 19:17:50 UTC 2010
Hi wp-hackers,
In the title element of my pages I have this structure that displays the
number of the current multipage page plus the total number of pages:
«cat-name» Category Archive - Blog Name [this is the first page]
«cat-name» Category Archive | Page 2 of 13 - Blog Name
«cat-name» Category Archive | Page 11 of 13 - Blog Name
and so on...
The same structure is used on all archive pages, search pages, etc.
The code successfully used is:
if (is_category()) {
echo '«'.single_cat_title('', false).'» Category Archive';
if ($paged) { echo ' | Page '.$paged.' of '.$wp_query->max_num_pages;
}
The problem is on single and page pages where I'm not able to get the
total number of pages. I tried:
if ($page) { echo ' | Page '.$page.' of '.$numpages; }
and
if ($page) { echo ' | Page '.$page.' of '.count($pages); }
but $numpages and $pages are active only during the loop.
How can I access the total number of pages of a multipage post or page
in the head section?
--
Aldo Latino
OpenPGP key: 4096R/0xA18E41E8 | bit.ly/keyDSA
More information about the wp-hackers
mailing list