Ticket #28439: 28439.2.patch
File 28439.2.patch, 1.1 KB (added by , 9 years ago) |
---|
-
wp-includes/taxonomy.php
1385 1385 $orderby = 't.slug'; 1386 1386 } else if ( 'term_group' == $_orderby ) { 1387 1387 $orderby = 't.term_group'; 1388 } else if ( 'post_date' == $_orderby ) { 1389 $orderby = 'p.post_date'; 1388 1390 } else if ( 'none' == $_orderby ) { 1389 1391 $orderby = ''; 1390 1392 } elseif ( empty($_orderby) || 'id' == $_orderby ) { … … 1561 1563 1562 1564 $join = "INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id"; 1563 1565 1566 // if we're ordering by date, we need to SELECT DISTINCT and JOIN term_relationships and posts 1567 if ( 'post_date' == $_orderby ) { 1568 $fields = "DISTINCT " . $fields; 1569 // JOIN with wp_term_relationships 1570 $join .= " JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id"; 1571 // JOIN with wp_posts 1572 $join .= " JOIN $wpdb->posts AS p ON p.ID = tr.object_id"; 1573 } 1574 1564 1575 $pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' ); 1565 1576 1566 1577 /**