WordPress.org

Make WordPress Core

Changeset 5004


Ignore:
Timestamp:
03/09/2007 04:09:24 AM (11 years ago)
Author:
ryan
Message:

get_archives query filters from westi. fixes #3866

File:
1 edited

Legend:

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

    r5003 r5004  
    351351    $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));
    352352
     353    //filters
     354    $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
     355    $join = apply_filters('getarchives_join', "", $r);
     356
    353357    if ( 'monthly' == $type ) {
    354         $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_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
     358        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
    355359        if ( $arcresults ) {
    356360            $afterafter = $after;
     
    364368        }
    365369    } elseif ('yearly' == $type) {
    366          $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts WHERE post_type ='post' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date DESC" . $limit);
     370         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC" . $limit);
    367371        if ($arcresults) {
    368372            $afterafter = $after;
     
    376380        }
    377381    } elseif ( 'daily' == $type ) {
    378         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC" . $limit);
     382        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC" . $limit);
    379383        if ( $arcresults ) {
    380384            $afterafter = $after;
     
    390394    } elseif ( 'weekly' == $type ) {
    391395        $start_of_week = get_option('start_of_week');
    392         $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, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC" . $limit);
     396        $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, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC" . $limit);
    393397        $arc_w_last = '';
    394398        $afterafter = $after;
     
    411415    } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
    412416        ('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC ";
    413         $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY $orderby $limit");
     417        $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts $join $where $orderby $limit");
    414418        if ( $arcresults ) {
    415419            foreach ( $arcresults as $arcresult ) {
Note: See TracChangeset for help on using the changeset viewer.