Get all children page ID’s including parent by title
You have done this the hard way. WP_Query can do most of the work for you. function get_all_pages($page_title) { $page = get_page_by_title($page_title); if (empty($page)) return array(); $children = new WP_Query( array( ‘post_type’ => ‘page’, ‘post_parent’ => $page->ID, ‘fields’ => ‘ids’ ) ); array_unshift($children->posts,”{$page->ID}”); return $children->posts; } $allpages = get_all_pages(‘Sample Page’); var_dump($allpages); It is late, and … Read more