Gotta be a better way to get an array of Child Page IDs than this. WordPress
<?php | |
// basic idea here is a common function to pass a parent page ID | |
// and get back an array of it and its child page IDs only | |
function getChildPageIDs( $id ) { | |
$child_pages = get_pages('child_of='.$id); | |
$ids_to_remove = array($id); // we want to remove parent id too | |
foreach($child_pages as $child) { | |
array_push($ids_to_remove,$child->ID); // for every child add the id into array | |
} | |
return $ids_to_remove; // send it all back | |
} | |
return getChildPageIDs( '123' ); | |
// there's gotta be a better way to do this no? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment