WordPress.org

Make WordPress Core

Ticket #13041: 12601.2.diff

File 12601.2.diff, 963 bytes (added by dd32, 4 years ago)
  • canonical.php

     
    367367 
    368368        $where = $wpdb->prepare("post_name LIKE %s", get_query_var('name') . '%'); 
    369369 
    370         // if any of post_type, year, monthnum, or day are set, use them to refine the query 
     370        // If any query variables are present that can refine the query, use them 
    371371        if ( get_query_var('post_type') ) 
    372372                $where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type')); 
     373        elseif ( get_query_var('name') && ! get_query_var('pagename') ) // If the request has specified a "name" var, but not a "pagename" var, it's a request matched upon the Post Permalink structure. not a page structure. 
     374                $where .= " AND post_type = 'post'"; 
     375 
    373376        if ( get_query_var('year') ) 
    374377                $where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year')); 
    375378        if ( get_query_var('monthnum') )