Make WordPress Core

Changeset 10646


Ignore:
Timestamp:
02/25/2009 05:09:29 PM (16 years ago)
Author:
ryan
Message:

Revert get_calendar() changes from [10602]. Broke calendar links. see #8351

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/general-template.php

    r10630 r10646  
    928928    // Quick check. If we have no posts at all, abort!
    929929    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");
    931931        if ( !$gotsome )
    932932            return;
     
    962962
    963963    // 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 year
     964    $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
    965965        FROM $wpdb->posts
    966966        WHERE post_date < '$thisyear-$thismonth-01'
     
    968968            ORDER BY post_date DESC
    969969            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
    972971        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' )
    974974        AND post_type = 'post' AND post_status = 'publish'
    975975            ORDER   BY post_date ASC
     
    10261026    // Get days with posts
    10271027    $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'
    10291030        AND post_type = 'post' AND post_status = 'publish'
    10301031        AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
     
    10451046    $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
    10461047        ."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' "
    10481050        ."AND post_date < '".current_time('mysql')."' "
    10491051        ."AND post_type = 'post' AND post_status = 'publish'"
Note: See TracChangeset for help on using the changeset viewer.