WordPress.org

Make WordPress Core

Ticket #16574: 16574.3.diff

File 16574.3.diff, 777 bytes (added by johnjamesjacoby, 4 years ago)

Just use get_post instead of get_posts

  • post.php

     
    45824582                return; 
    45834583 
    45844584        $id = $_post->ancestors[] = $_post->post_parent; 
    4585         while ( $ancestor = $wpdb->get_var( $wpdb->prepare("SELECT `post_parent` FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id) ) ) { 
     4585 
     4586        while ( $ancestor = get_post( $id ) ) { 
    45864587                // Loop detection: If the ancestor has been seen before, break. 
    4587                 if ( ( $ancestor == $_post->ID ) || in_array($ancestor,  $_post->ancestors) ) 
     4588                if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $_post->ID ) || in_array($ancestor->post_parent,  $_post->ancestors) ) 
    45884589                        break; 
    4589                 $id = $_post->ancestors[] = $ancestor; 
     4590                $id = $_post->ancestors[] = $ancestor->post_parent; 
    45904591        } 
    45914592} 
    45924593