Make WordPress Core


Ignore:
Timestamp:
02/09/2006 10:03:48 AM (19 years ago)
Author:
ryan
Message:

Allow draft pages. Use post_type for object types. Reserve post_status strictly for status. fixes #1820

File:
1 edited

Legend:

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

    r3493 r3510  
    331331
    332332    if ( 'monthly' == $type ) {
    333         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
     333        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
    334334        if ( $arcresults ) {
    335335            $afterafter = $after;
     
    346346        }
    347347    } elseif ( 'daily' == $type ) {
    348         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
     348        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    349349        if ( $arcresults ) {
    350350            foreach ( $arcresults as $arcresult ) {
     
    357357    } elseif ( 'weekly' == $type ) {
    358358        $start_of_week = get_settings('start_of_week');
    359         $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
     359        $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    360360        $arc_w_last = '';
    361361        if ( $arcresults ) {
     
    374374        }
    375375    } elseif ( 'postbypost' == $type ) {
    376         $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
     376        $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    377377        if ( $arcresults ) {
    378378            foreach ( $arcresults as $arcresult ) {
     
    404404    // Quick check. If we have no posts at all, abort!
    405405    if ( !$posts ) {
    406         $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_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
    407407        if ( !$gotsome )
    408408            return;
     
    444444        FROM $wpdb->posts
    445445        WHERE post_date < '$thisyear-$thismonth-01'
    446         AND post_status = 'publish'
     446        AND post_type = 'post' AND post_status = 'publish'
    447447            ORDER BY post_date DESC
    448448            LIMIT 1");
     
    451451        WHERE post_date >   '$thisyear-$thismonth-01'
    452452        AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
    453         AND post_status = 'publish'
     453        AND post_type = 'post' AND post_status = 'publish'
    454454            ORDER   BY post_date ASC
    455455            LIMIT 1");
     
    509509        FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth
    510510        AND YEAR(post_date) = $thisyear
    511         AND post_status = 'publish'
     511        AND post_type = 'post' AND post_status = 'publish'
    512512        AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
    513513    if ( $dayswithposts ) {
     
    532532        ."AND MONTH(post_date) = '$thismonth' "
    533533        ."AND post_date < '".current_time('mysql')."' "
    534         ."AND post_status = 'publish'"
     534        ."AND post_type = 'post' AND post_status = 'publish'"
    535535    );
    536536    if ( $ak_post_titles ) {
Note: See TracChangeset for help on using the changeset viewer.