From e2f641e457447863dd984e2a8b6369e0106bc45d Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 30 Aug 2006 17:23:42 +0000 Subject: [PATCH] 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 --- wp-includes/general-template.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 73592b17a0..2c263ae637 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -332,6 +332,21 @@ function wp_get_archives($args = '') { 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 ) { $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 ) {