diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 0ecf9a1ad7..0fb1dfa348 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -4300,7 +4300,7 @@ function get_page_uri( $page ) { foreach ( $page->ancestors as $parent ) { $parent = get_post( $parent ); - if ( 'publish' === $parent->post_status ) { + if ( $parent ) { $uri = $parent->post_name . '/' . $uri; } } diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index f98786e2f3..a1ec373be8 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -674,8 +674,8 @@ class Tests_Post extends WP_UnitTestCase { // try the child normally $this->assertEquals( 'parent/child', get_page_uri( $child_id ) ); - // now delete the parent and check - wp_delete_post( $parent_id ); + // now delete the parent from the database and check + wp_delete_post( $parent_id, true ); $this->assertEquals( 'child', get_page_uri( $child_id ) ); }