Make WordPress Core


Ignore:
Timestamp:
09/26/2003 07:03:35 AM (22 years ago)
Author:
mikelittle
Message:

Added display of post count on monthly archives

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2-include/b2template.functions.php

    r377 r388  
    122122}
    123123
    124 function get_archives($type='', $limit='', $format='html', $before = "", $after = "") {
     124function get_archives($type='', $limit='', $format='html', $before = "", $after = "", $show_post_count = false) {
    125125    global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename;
    126126    global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb, $start_of_week, $querycount;
     
    162162    if ('monthly' == $type) {
    163163        ++$querycount;
    164         $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);
     164        $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);
    165165        if ($arcresults) {
    166166            foreach ($arcresults as $arcresult) {
    167167                $url  = sprintf("%s%d%02d", $archive_link_m,  $arcresult->year,   $arcresult->month);
    168                 $text = sprintf("%s %d",    $month[zeroise($arcresult->month,2)], $arcresult->year);
     168                if ($show_post_count)
     169                    $text = sprintf("%s %d (%d)", $month[zeroise($arcresult->month,2)], $arcresult->year, $arcresult->posts);
     170                else
     171                    $text = sprintf("%s %d", $month[zeroise($arcresult->month,2)], $arcresult->year);
    169172                echo get_archives_link($url, $text, $format, $before, $after);
    170173            }
Note: See TracChangeset for help on using the changeset viewer.