From 18d2eb783898daeb1d89aa3a07034ac1ffea2b53 Mon Sep 17 00:00:00 2001 From: Mike Little Date: Fri, 26 Sep 2003 07:03:35 +0000 Subject: [PATCH] Added display of post count on monthly archives git-svn-id: https://develop.svn.wordpress.org/trunk@388 602fd350-edb4-49c9-b593-d223f7449a82 --- b2-include/b2template.functions.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/b2-include/b2template.functions.php b/b2-include/b2template.functions.php index 6f3d7c598a..645618f8c2 100644 --- a/b2-include/b2template.functions.php +++ b/b2-include/b2template.functions.php @@ -121,7 +121,7 @@ function get_archives_link($url, $text, $format = "html", $before = "", $after = } } -function get_archives($type='', $limit='', $format='html', $before = "", $after = "") { +function get_archives($type='', $limit='', $format='html', $before = "", $after = "", $show_post_count = false) { global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename; global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb, $start_of_week, $querycount; @@ -161,11 +161,14 @@ function get_archives($type='', $limit='', $format='html', $before = "", $after if ('monthly' == $type) { ++$querycount; - $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 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`, count(ID) as posts FROM $tableposts WHERE post_date < '$now' AND post_category > 0 AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); if ($arcresults) { foreach ($arcresults as $arcresult) { $url = sprintf("%s%d%02d", $archive_link_m, $arcresult->year, $arcresult->month); - $text = sprintf("%s %d", $month[zeroise($arcresult->month,2)], $arcresult->year); + if ($show_post_count) + $text = sprintf("%s %d (%d)", $month[zeroise($arcresult->month,2)], $arcresult->year, $arcresult->posts); + else + $text = sprintf("%s %d", $month[zeroise($arcresult->month,2)], $arcresult->year); echo get_archives_link($url, $text, $format, $before, $after); } }