Make WordPress Core

Ticket #2472: post-page-slug-clash.diff

File post-page-slug-clash.diff, 1.0 KB (added by davidhouse, 19 years ago)

Exactly the same patch in SVN diff format

  • wp-includes/functions.php

     
    675675        foreach($page_paths as $pathdir)
    676676                $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
    677677
    678         $pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = '$leaf_path'");
     678        $pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = '$leaf_path' AND post_type='page'");
    679679
    680680        if ( empty($pages) )
    681681                return 0;
     
    684684                $path = '/' . $leaf_path;
    685685                $curpage = $page;
    686686                while ($curpage->post_parent != 0) {
    687                         $curpage = $wpdb->get_row("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = '$curpage->post_parent'");
     687                        $curpage = $wpdb->get_row("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = '$curpage->post_parent' and post_type='page'");
    688688                        $path = '/' . $curpage->post_name . $path;
    689689                }
    690690