Languages: English • Italiano • 日本語 (Add your language)
Retrieve child pages from list of pages matching page ID.
Matches against the pages parameter against the page ID. Also matches all children for the same to retrieve all children of a page. Does not make any SQL queries to get the children.
<?php get_page_children( $page_id, $pages ); ?>
<?php // Set up the objects needed $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array('post_type' => 'page', 'posts_per_page' => '-1')); // Get the page as an Object $portfolio = get_page_by_title('Portfolio'); // Filter through all pages and find Portfolio's children $portfolio_children = get_page_children( $portfolio->ID, $all_wp_pages ); // echo what we get back from WP to the browser echo '<pre>' . print_r( $portfolio_children, true ) . '</pre>'; ?>
This function calls itself recursively.
Since: 1.5.1
get_page_children() is located in wp-includes/post.php
.
Page Tags: get_all_page_ids(), get_ancestors(), get_page(), get_page_link(), get_page_by_path(), get_page_by_title(), get_page_children(), get_page_hierarchy(), get_page_uri(), get_pages(), is_page(), page_uri_index(), wp_list_pages(), wp_page_menu()