Changeset 10646
- Timestamp:
- 02/25/2009 05:09:29 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/general-template.php
r10630 r10646 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' LIMIT 1");930 $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC 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 MONTH(post_date) AS month, YEAR(post_date) AS year964 $previous = $wpdb->get_row("SELECT DISTINCT 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 $last_day = date('t'); 971 $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year 970 $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 972 971 FROM $wpdb->posts 973 WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59' 972 WHERE post_date > '$thisyear-$thismonth-01' 973 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) 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 post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' 1028 FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' 1029 AND YEAR(post_date) = '$thisyear' 1029 1030 AND post_type = 'post' AND post_status = 'publish' 1030 1031 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); … … 1045 1046 $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " 1046 1047 ."FROM $wpdb->posts " 1047 ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' " 1048 ."WHERE YEAR(post_date) = '$thisyear' " 1049 ."AND MONTH(post_date) = '$thismonth' " 1048 1050 ."AND post_date < '".current_time('mysql')."' " 1049 1051 ."AND post_type = 'post' AND post_status = 'publish'"
Note: See TracChangeset
for help on using the changeset viewer.