WordPress.org

Make WordPress Core

Ticket #2961: calendar_future_posts_001.diff

File calendar_future_posts_001.diff, 1.2 KB (added by markjaquith, 14 years ago)

Patch for /branches/2.0/

  • wp-includes/template-functions-general.php

     
    399399function get_calendar($daylength = 1) {
    400400        global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;
    401401
    402         // Quick check. If we have no posts at all, abort!
     402        $now = current_time('mysql');
     403
     404        // Quick check. If we have no posts yet published, abort!
    403405        if ( !$posts ) {
    404                 $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
     406                $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' AND post_date < '$now' ORDER BY post_date DESC LIMIT 1");
    405407                if ( !$gotsome )
    406408                        return;
    407409        }
     
    447449        $next = $wpdb->get_row("SELECT  DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
    448450                FROM $wpdb->posts
    449451                WHERE post_date >       '$thisyear-$thismonth-01'
     452                AND post_date < '$now'
    450453                AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
    451454                AND post_status = 'publish'
    452455                        ORDER   BY post_date ASC