Make WordPress Core


Ignore:
Timestamp:
11/01/2014 08:43:55 PM (10 years ago)
Author:
wonderboymusic
Message:

Allow get_pages(), with child_of passed to it, to work with interrupted hierarchies.

Adds unit test.
Fixes #18962.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r30158 r30159  
    42864286    $page_list = array();
    42874287    foreach ( (array) $pages as $page ) {
    4288         if ( $page->post_parent == $page_id ) {
     4288        if ( $page->post_parent == $page_id || in_array( $page_id, $page->ancestors ) ) {
    42894289            $page_list[] = $page;
    42904290            if ( $children = get_page_children($page->ID, $pages) )
     
    46204620    update_post_cache( $pages );
    46214621
     4622    // Convert to WP_Post instances
     4623    $pages = array_map( 'get_post', $pages );
     4624
    46224625    if ( $child_of || $hierarchical ) {
    46234626        $pages = get_page_children($child_of, $pages);
     
    46474650
    46484651    wp_cache_set( $cache_key, $page_structure, 'posts' );
    4649 
    4650     // Convert to WP_Post instances.
    4651     $pages = array_map( 'get_post', $pages );
    46524652
    46534653    /**
Note: See TracChangeset for help on using the changeset viewer.