Add yearly archive display option. Props stewart and westi. fixes #2352

git-svn-id: http://svn.automattic.com/wordpress/trunk@4138 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-08-30 17:23:42 +00:00
parent db5d9a84ba
commit e2f641e457

View File

@ -332,6 +332,21 @@ function wp_get_archives($args = '') {
echo get_archives_link($url, $text, $format, $before, $after); echo get_archives_link($url, $text, $format, $before, $after);
} }
} }
} elseif ('yearly' == $type) {
$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);
if ($arcresults) {
$afterafter = $after;
foreach ($arcresults as $arcresult) {
$url = get_year_link($arcresult->year);
if ($show_post_count) {
$text = sprintf('%d', $arcresult->year);
$after = ' ('.$arcresult->posts.')' . $afterafter;
} else {
$text = sprintf('%d', $arcresult->year);
}
echo get_archives_link($url, $text, $format, $before, $after);
}
}
} elseif ( 'daily' == $type ) { } 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_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); $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_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
if ( $arcresults ) { if ( $arcresults ) {