Return to Snippet

Revision: 39899
at January 23, 2011 10:49 by lexpresso


Updated Code
<?php 
//get the sub pages for the parent page
    $subPages = get_pages('child_of=parent_page_id');
    //$i will equal the page number
    $i=1;
    foreach($subPages as $subs){
        //not sure what the exact array key for page_id will be. use var_dump($subPages)to find out
        //make the array key the page id for use later (as current_page_id)
        $pageNumber[$subs->page_id] = $i;
    }
    $numberPages = count($pageNumbers);

    // Then show the page count and number pages for the page you are on.

    echo 'vewing page '.$pageNumber[current_page_id].' of '.$numberPages;

?>

Revision: 39898
at January 23, 2011 04:10 by lexpresso


Updated Code
<?php 
//get the sub pages for the parent page
    $subPages = get_pages('child_of'=>parent_page_id);
    //$i will equal the page number
    $i=1;
    foreach($subPages as $subs){
        //not sure what the exact array key for page_id will be. use var_dump($subPages)to find out
        //make the array key the page id for use later (as current_page_id)
        $pageNumber[$subs->page_id] = $i;
    }
    $numberPages = count($pageNumbers);

    // Then show the page count and number pages for the page you are on.

    echo 'vewing page '.$pageNumber[current_page_id].' of '.$numberPages;

?>

Revision: 39897
at January 22, 2011 08:23 by lexpresso


Initial Code
<?php 
//get the sub pages for the parent page
    $subPages = get_pages('child_of'=>parent_page_id);
    //$i will equal the page number
    $i=1;
    foreach($subPages as $subs){
        //not sure what the exact array key for page_id will be. use var_dump($subPages)to find out
        //make the array key the page id for use later (as current_page_id)
        $pageNumber[$subs->page_id] = $i;
    }
    $numberPages = count($pageNumbers);
?>

Initial URL

                                

Initial Description

                                

Initial Title
WP: Get Parent Subpage Count

Initial Tags
wordpress

Initial Language
PHP