Ticket #18832: 18832.2.diff
File 18832.2.diff, 3.2 KB (added by , 14 years ago) |
---|
-
wp-includes/general-template.php
863 863 'type' => 'monthly', 'limit' => '', 864 864 'format' => 'html', 'before' => '', 865 865 'after' => '', 'show_post_count' => false, 866 'echo' => 1 866 'echo' => 1, 'order' => 'DESC' 867 867 ); 868 868 869 869 $r = wp_parse_args( $args, $defaults ); 870 870 extract( $r, EXTR_SKIP ); 871 871 872 872 if ( '' == $type ) 873 873 $type = 'monthly'; 874 874 … … 877 877 $limit = ' LIMIT '.$limit; 878 878 } 879 879 880 if ( 'ASC' != strtoupper( $order ) ) { 881 $order = 'DESC'; 882 } 883 880 884 // this is what will separate dates on weekly archive links 881 885 $archive_week_separator = '–'; 882 886 … … 903 907 $output = ''; 904 908 905 909 if ( 'monthly' == $type ) { 906 $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC$limit";910 $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit"; 907 911 $key = md5($query); 908 912 $cache = wp_cache_get( 'wp_get_archives' , 'general'); 909 913 if ( !isset( $cache[ $key ] ) ) { … … 925 929 } 926 930 } 927 931 } elseif ('yearly' == $type) { 928 $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC$limit";932 $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit"; 929 933 $key = md5($query); 930 934 $cache = wp_cache_get( 'wp_get_archives' , 'general'); 931 935 if ( !isset( $cache[ $key ] ) ) { … … 946 950 } 947 951 } 948 952 } elseif ( 'daily' == $type ) { 949 $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC$limit";953 $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit"; 950 954 $key = md5($query); 951 955 $cache = wp_cache_get( 'wp_get_archives' , 'general'); 952 956 if ( !isset( $cache[ $key ] ) ) { … … 969 973 } 970 974 } elseif ( 'weekly' == $type ) { 971 975 $week = _wp_mysql_week( '`post_date`' ); 972 $query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` DESC$limit";976 $query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit"; 973 977 $key = md5($query); 974 978 $cache = wp_cache_get( 'wp_get_archives' , 'general'); 975 979 if ( !isset( $cache[ $key ] ) ) {