WordPress.org

Make WordPress Core

Ticket #15487: 15487-2.diff

File 15487-2.diff, 1.8 KB (added by greuben, 4 years ago)

need some more testing

  • wp-includes/query.php

     
    26522652                        return $this->queried_object; 
    26532653 
    26542654                $this->queried_object = NULL; 
    2655                 $this->queried_object_id = 0; 
    2656  
    2657                 if ( $this->is_category || $this->is_tag || $this->is_tax ) { 
     2655                $this->queried_object_id = 0;    
     2656                 
     2657                if ( ( $this->is_category || $this->is_tag || $this->is_tax ) && !$this->is_single ) { 
    26582658                        $tax_query_in = wp_list_filter( $this->tax_query->queries, array( 'operator' => 'IN' ) ); 
    26592659 
    26602660                        $query = reset( $tax_query_in ); 
     
    26812681                        $this->queried_object_id = (int) $this->get('author'); 
    26822682                        $this->queried_object = get_userdata( $this->queried_object_id ); 
    26832683                } 
    2684  
     2684                 
    26852685                return $this->queried_object; 
    26862686        } 
    26872687 
  • 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 )