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); if ( $arcresults ) { $afterafter = $after; foreach ( $arcresults as $arcresult ) { $url = get_month_link($arcresult->year, $arcresult->month); if ( $show_post_count ) { $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year); $before = ''.$arcresult->posts.' Posts'.$afterafter; } else { $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year); } echo get_archives_link_plus($url, $text, $format, $before, $after); } } } 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_date != '0000-00-00 00:00:00' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); if ( $arcresults ) { foreach ( $arcresults as $arcresult ) { $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth); $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth); $text = mysql2date($archive_day_date_format, $date); echo get_archives_link_plus($url, $text, $format, $before, $after); } } } 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); $arc_w_last = ''; if ( $arcresults ) { foreach ( $arcresults as $arcresult ) { if ( $arcresult->week != $arc_w_last ) { $arc_year = $arcresult->yr; $arc_w_last = $arcresult->week; $arc_week = get_weekstartend($arcresult->yyyymmdd, get_settings('start_of_week')); $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']); $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']); $url = sprintf('%s/%s%sm%s%s%sw%s%d', get_settings('home'), '', '?', '=', $arc_year, '&', '=', $arcresult->week); $text = $arc_week_start . $archive_week_separator . $arc_week_end; echo get_archives_link_plus($url, $text, $format, $before, $after); } } } } 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); if ( $arcresults ) { foreach ( $arcresults as $arcresult ) { if ( $arcresult->post_date != '0000-00-00 00:00:00' ) { $url = get_permalink($arcresult); $arc_title = $arcresult->post_title; if ( $arc_title ) $text = strip_tags($arc_title); else $text = $arcresult->ID; echo get_archives_link_plus($url, $text, $format, $before, $after); } } } } } /* this is a mod version of the function 'get_archives_link', by Sparanoid */ function get_archives_link_plus($url, $text, $format = 'html', $before = '', $after = '') { $text = wptexturize($text); $title_text = wp_specialchars($text, 1); if ('link' == $format) return "\t\n"; elseif ('option' == $format) return "\t\n"; elseif ('html' == $format) return "\t