OK, so what we want to achieve is to write a function that will take a title of a page and return the array containing its ID and IDs of its children. So here’s the code:
function get_page_and_its_children_ids_by_title( $page_title ) {
$result = array();
$page = get_page_by_title( $page_title ); // find page with given title
if ( $page ) { // if that page exists
$result[] = $page->ID; // add its ID to the result
$children = get_children( array( // get its children
'post_parent' => $page->ID,
'post_type' => 'page',
'numberposts' => -1,
'post_status' => 'publish'
) );
$result = array_merge( $result, array_keys( $children ) ); // add children ids to the result
}
return $result;
}