WordPress.org

Make WordPress Core

Ticket #15487: 15487.diff

File 15487.diff, 1010 bytes (added by greuben, 3 years ago)
  • wp-includes/canonical.php

     
    6666        if ( !isset($redirect['query']) ) 
    6767                $redirect['query'] = ''; 
    6868 
    69         if ( is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p')) ) { 
     69        if ( is_singular() && 1 >= $wp_query->post_count ) { 
     70         
     71                $id = get_query_var('p'); 
     72                $name = get_query_var('name');           
    7073 
    71                 $vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) ); 
     74                if( $id ) 
     75                        $vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) ); 
     76                elseif( $name ) 
     77                        $vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE post_name = %s", $name) ); 
    7278 
    7379                if ( isset($vars[0]) && $vars = $vars[0] ) { 
    7480                        if ( 'revision' == $vars->post_type && $vars->post_parent > 0 )