| 1 | Index: wp-includes/general-template.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/general-template.php (revision 18873) |
|---|
| 4 | +++ wp-includes/general-template.php (working copy) |
|---|
| 5 | @@ -863,12 +863,12 @@ |
|---|
| 6 | 'type' => 'monthly', 'limit' => '', |
|---|
| 7 | 'format' => 'html', 'before' => '', |
|---|
| 8 | 'after' => '', 'show_post_count' => false, |
|---|
| 9 | - 'echo' => 1 |
|---|
| 10 | + 'echo' => 1, 'order' => 'DESC' |
|---|
| 11 | ); |
|---|
| 12 | |
|---|
| 13 | $r = wp_parse_args( $args, $defaults ); |
|---|
| 14 | extract( $r, EXTR_SKIP ); |
|---|
| 15 | - |
|---|
| 16 | + |
|---|
| 17 | if ( '' == $type ) |
|---|
| 18 | $type = 'monthly'; |
|---|
| 19 | |
|---|
| 20 | @@ -877,6 +877,10 @@ |
|---|
| 21 | $limit = ' LIMIT '.$limit; |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | + if ( 'ASC' != strtoupper( $order ) ) { |
|---|
| 25 | + $order = 'DESC'; |
|---|
| 26 | + } |
|---|
| 27 | + |
|---|
| 28 | // this is what will separate dates on weekly archive links |
|---|
| 29 | $archive_week_separator = '–'; |
|---|
| 30 | |
|---|
| 31 | @@ -903,7 +907,7 @@ |
|---|
| 32 | $output = ''; |
|---|
| 33 | |
|---|
| 34 | if ( 'monthly' == $type ) { |
|---|
| 35 | - $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"; |
|---|
| 36 | + $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"; |
|---|
| 37 | $key = md5($query); |
|---|
| 38 | $cache = wp_cache_get( 'wp_get_archives' , 'general'); |
|---|
| 39 | if ( !isset( $cache[ $key ] ) ) { |
|---|
| 40 | @@ -925,7 +929,7 @@ |
|---|
| 41 | } |
|---|
| 42 | } |
|---|
| 43 | } elseif ('yearly' == $type) { |
|---|
| 44 | - $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"; |
|---|
| 45 | + $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"; |
|---|
| 46 | $key = md5($query); |
|---|
| 47 | $cache = wp_cache_get( 'wp_get_archives' , 'general'); |
|---|
| 48 | if ( !isset( $cache[ $key ] ) ) { |
|---|
| 49 | @@ -946,7 +950,7 @@ |
|---|
| 50 | } |
|---|
| 51 | } |
|---|
| 52 | } elseif ( 'daily' == $type ) { |
|---|
| 53 | - $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"; |
|---|
| 54 | + $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"; |
|---|
| 55 | $key = md5($query); |
|---|
| 56 | $cache = wp_cache_get( 'wp_get_archives' , 'general'); |
|---|
| 57 | if ( !isset( $cache[ $key ] ) ) { |
|---|
| 58 | @@ -969,7 +973,7 @@ |
|---|
| 59 | } |
|---|
| 60 | } elseif ( 'weekly' == $type ) { |
|---|
| 61 | $week = _wp_mysql_week( '`post_date`' ); |
|---|
| 62 | - $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"; |
|---|
| 63 | + $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"; |
|---|
| 64 | $key = md5($query); |
|---|
| 65 | $cache = wp_cache_get( 'wp_get_archives' , 'general'); |
|---|
| 66 | if ( !isset( $cache[ $key ] ) ) { |
|---|