Skip to content

Commit eb692e1

Browse files
Fix get_page_children to handle parent ID checks
1 parent 02a10d7 commit eb692e1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/wp-includes/post.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6271,7 +6271,13 @@ function get_page_children( $page_id, $pages ) {
62716271
$page_ids = wp_list_pluck( $pages, 'ID' );
62726272

62736273
foreach ( $parent_ids as $parent_id ) {
6274-
if ( 0 !== $parent_id && ! in_array( $parent_id, $page_ids, true ) ) {
6274+
if ( 0 === $parent_id || in_array( $parent_id, $page_ids, true ) ) {
6275+
continue;
6276+
}
6277+
6278+
$parent_exists = (bool) get_post( $parent_id );
6279+
6280+
if ( $parent_exists && isset( $children[ $parent_id ] ) ) {
62756281
foreach ( $children[ $parent_id ] as $orphan ) {
62766282
$page_list[] = $orphan;
62776283
if ( isset( $children[ $orphan->ID ] ) ) {

0 commit comments

Comments
 (0)