Respect the fields
arg when passed to get_children()
.
Fixes #22208. git-svn-id: https://develop.svn.wordpress.org/trunk@25160 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
95cab73341
commit
744a4a80a4
@ -311,9 +311,12 @@ function get_children($args = '', $output = OBJECT) {
|
||||
|
||||
$children = get_posts( $r );
|
||||
|
||||
if ( !$children )
|
||||
if ( ! $children )
|
||||
return $kids;
|
||||
|
||||
if ( ! empty( $r['fields'] ) )
|
||||
return $children;
|
||||
|
||||
update_post_cache($children);
|
||||
|
||||
foreach ( $children as $key => $child )
|
||||
|
@ -117,4 +117,15 @@ class Tests_Post_getPages extends WP_UnitTestCase {
|
||||
|
||||
$this->assertEquals( 5, count( $matches[0] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 22208
|
||||
*/
|
||||
function test_get_chidren_fields_ids() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$child_ids = $this->factory->post->create_many( 5, array( 'post_parent' => $post_id ) );
|
||||
|
||||
$post_ids = get_children( array( 'fields' => 'ids', 'post_parent' => $post_id ) );
|
||||
$this->assertEqualSets( $child_ids, $post_ids );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user