From b17c5d427be1b28cb7a0547aa40dc86292d3ad28 Mon Sep 17 00:00:00 2001 From: Ryan Boren 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: https://develop.svn.wordpress.org/trunk@4138 602fd350-edb4-49c9-b593-d223f7449a82 --- 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 ) {