Changeset 10602
- Timestamp:
- 02/19/2009 10:53:19 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/general-template.php
r10558 r10602 761 761 762 762 if ( 'monthly' == $type ) { 763 $query = "SELECT DISTINCTYEAR(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";763 $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"; 764 764 $key = md5($query); 765 765 $cache = wp_cache_get( 'wp_get_archives' , 'general'); … … 782 782 } 783 783 } elseif ('yearly' == $type) { 784 $query = "SELECT DISTINCTYEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC $limit";784 $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"; 785 785 $key = md5($query); 786 786 $cache = wp_cache_get( 'wp_get_archives' , 'general'); … … 803 803 } 804 804 } elseif ( 'daily' == $type ) { 805 $query = "SELECT DISTINCTYEAR(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";805 $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"; 806 806 $key = md5($query); 807 807 $cache = wp_cache_get( 'wp_get_archives' , 'general'); … … 928 928 // Quick check. If we have no posts at all, abort! 929 929 if ( !$posts ) { 930 $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESCLIMIT 1");930 $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1"); 931 931 if ( !$gotsome ) 932 932 return; … … 962 962 963 963 // Get the next and previous month and year with at least one post 964 $previous = $wpdb->get_row("SELECT DISTINCTMONTH(post_date) AS month, YEAR(post_date) AS year964 $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year 965 965 FROM $wpdb->posts 966 966 WHERE post_date < '$thisyear-$thismonth-01' … … 968 968 ORDER BY post_date DESC 969 969 LIMIT 1"); 970 $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 970 $last_day = date('t'); 971 $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year 971 972 FROM $wpdb->posts 972 WHERE post_date > '$thisyear-$thismonth-01' 973 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) 973 WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59' 974 974 AND post_type = 'post' AND post_status = 'publish' 975 975 ORDER BY post_date ASC … … 1026 1026 // Get days with posts 1027 1027 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) 1028 FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' 1029 AND YEAR(post_date) = '$thisyear' 1028 FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' 1030 1029 AND post_type = 'post' AND post_status = 'publish' 1031 1030 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); … … 1046 1045 $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " 1047 1046 ."FROM $wpdb->posts " 1048 ."WHERE YEAR(post_date) = '$thisyear' " 1049 ."AND MONTH(post_date) = '$thismonth' " 1047 ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' " 1050 1048 ."AND post_date < '".current_time('mysql')."' " 1051 1049 ."AND post_type = 'post' AND post_status = 'publish'"
Note: See TracChangeset
for help on using the changeset viewer.