Posted By

lexpresso on 01/22/11


Tagged

pages wordpress


Versions (?)

WP: Get Parent Subpage Count


 / Published in: PHP
 

  1. <?php
  2. //get the sub pages for the parent page
  3. $subPages = get_pages('child_of=parent_page_id');
  4. //$i will equal the page number
  5. $i=1;
  6. foreach($subPages as $subs){
  7. //not sure what the exact array key for page_id will be. use var_dump($subPages)to find out
  8. //make the array key the page id for use later (as current_page_id)
  9. $pageNumber[$subs->page_id] = $i;
  10. }
  11. $numberPages = count($pageNumbers);
  12.  
  13. // Then show the page count and number pages for the page you are on.
  14.  
  15. echo 'vewing page '.$pageNumber[current_page_id].' of '.$numberPages;
  16.  
  17. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: lexpresso on January 23, 2011

Got it from http://stackoverflow.com/questions/3393046/how-to-get-the-number-of-sub-page-child-pages-that-exist-in-wordpress

You need to login to post a comment.