WordPress.org

Make WordPress Core

Ticket #8444: 8444.discover-level.2.diff

File 8444.discover-level.2.diff, 719 bytes (added by jbsil, 9 years ago)

accounts for actual orphans

  • template.php

     
    15641564        $post = $page;
    15651565        setup_postdata($page);
    15661566
     1567        if ( 0 == $level && (int)$page->post_parent > 0) {
     1568                //sent level 0 by accident, by default, or because we don't know the actual level
     1569                $find_main_page = (int)$page->post_parent;
     1570                while ($find_main_page > 0) {
     1571                        $parent = get_page($find_main_page);
     1572                        if (is_null($parent)) break;
     1573                        $level++;
     1574                        $find_main_page = (int)$parent->post_parent;
     1575                }
     1576        }
     1577
    15671578        $page->post_title = wp_specialchars( $page->post_title );
    15681579        $pad = str_repeat( '— ', $level );
    15691580        $id = (int) $page->ID;