Revert get_calendar() changes from [10602]. Broke calendar links. see #8351
git-svn-id: http://svn.automattic.com/wordpress/trunk@10646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
eb5a33864e
commit
5719faff71
|
@ -927,7 +927,7 @@ function get_calendar($initial = true) {
|
|||
ob_start();
|
||||
// Quick check. If we have no posts at all, abort!
|
||||
if ( !$posts ) {
|
||||
$gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
|
||||
$gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
|
||||
if ( !$gotsome )
|
||||
return;
|
||||
}
|
||||
|
@ -961,16 +961,16 @@ function get_calendar($initial = true) {
|
|||
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
|
||||
|
||||
// Get the next and previous month and year with at least one post
|
||||
$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
$previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
FROM $wpdb->posts
|
||||
WHERE post_date < '$thisyear-$thismonth-01'
|
||||
AND post_type = 'post' AND post_status = 'publish'
|
||||
ORDER BY post_date DESC
|
||||
LIMIT 1");
|
||||
$last_day = date('t');
|
||||
$next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
$next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
|
||||
FROM $wpdb->posts
|
||||
WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
|
||||
WHERE post_date > '$thisyear-$thismonth-01'
|
||||
AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
|
||||
AND post_type = 'post' AND post_status = 'publish'
|
||||
ORDER BY post_date ASC
|
||||
LIMIT 1");
|
||||
|
@ -1025,7 +1025,8 @@ function get_calendar($initial = true) {
|
|||
|
||||
// Get days with posts
|
||||
$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
|
||||
FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
|
||||
FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth'
|
||||
AND YEAR(post_date) = '$thisyear'
|
||||
AND post_type = 'post' AND post_status = 'publish'
|
||||
AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
|
||||
if ( $dayswithposts ) {
|
||||
|
@ -1044,7 +1045,8 @@ function get_calendar($initial = true) {
|
|||
$ak_titles_for_day = array();
|
||||
$ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
|
||||
."FROM $wpdb->posts "
|
||||
."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
|
||||
."WHERE YEAR(post_date) = '$thisyear' "
|
||||
."AND MONTH(post_date) = '$thismonth' "
|
||||
."AND post_date < '".current_time('mysql')."' "
|
||||
."AND post_type = 'post' AND post_status = 'publish'"
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue