--- old/template-functions-general.php	2005-06-14 01:47:37.000000000 +0200
+++ new/template-functions-general.php	2005-06-16 21:18:05.000000000 +0200
@@ -297,7 +297,9 @@
     $now = current_time('mysql');
 
     if ('monthly' == $type) {
-        $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_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
+        $join = apply_filters('archive_join', '');
+        $where = apply_filters('archive_where', "WHERE post_date < '$now' AND post_status = 'publish'");
+        $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);
         if ($arcresults) {
             $afterafter = $after;
             foreach ($arcresults as $arcresult) {
@@ -312,7 +314,9 @@
             }
         }
     } elseif ('daily' == $type) {
-        $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_status = 'publish' ORDER BY post_date DESC" . $limit);
+        $join = apply_filters('archive_join', '');
+        $where = apply_filters('archive_where', "WHERE post_date < '$now' AND post_status = 'publish'");
+        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts $join $where ORDER BY post_date DESC" . $limit);
         if ($arcresults) {
             foreach ($arcresults as $arcresult) {
                 $url  = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
@@ -323,7 +327,9 @@
         }
     } elseif ('weekly' == $type) {
 	$start_of_week = get_settings('start_of_week');
-        $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);
+        $join = apply_filters('archive_join', '');
+        $where = apply_filters('archive_where', "WHERE post_date < '$now' AND post_status = 'publish'");
+        $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 $join $where ORDER BY post_date DESC" . $limit);
         $arc_w_last = '';
         if ($arcresults) {
             foreach ($arcresults as $arcresult) {
@@ -342,7 +348,9 @@
             }
         }
     } elseif ('postbypost' == $type) {
-        $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
+        $join = apply_filters('archive_join', '');
+        $where = apply_filters('archive_where', "WHERE post_date < '$now' AND post_status = 'publish'");
+        $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts $join $where ORDER BY post_date DESC" . $limit);
         if ($arcresults) {
             foreach ($arcresults as $arcresult) {
                 if ($arcresult->post_date != '0000-00-00 00:00:00') {

