WordPress.org

Make WordPress Core

Ticket #8022: postbypost_distinct.patch

File postbypost_distinct.patch, 646 bytes (added by kevinB, 7 years ago)

add DISTINCT clause to query for get_archives postbypost

  • general-template.php

     
    845845                } 
    846846        } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) { 
    847847                $orderby = ('alpha' == $type) ? "post_title ASC " : "post_date DESC "; 
    848                 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; 
     848                $query = "SELECT DISTINCT $wpdb->posts.* FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; 
    849849                $key = md5($query); 
    850850                $cache = wp_cache_get( 'wp_get_archives' , 'general'); 
    851851                if ( !isset( $cache[ $key ] ) ) {