WordPress.org

Make WordPress Core

Changeset 4138


Ignore:
Timestamp:
08/30/06 17:23:42 (9 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/general-template.php

    r4134 r4138  
    333333            } 
    334334        } 
     335    } elseif ('yearly' == $type) { 
     336         $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); 
     337        if ($arcresults) { 
     338            $afterafter = $after; 
     339            foreach ($arcresults as $arcresult) { 
     340                $url = get_year_link($arcresult->year); 
     341                if ($show_post_count) { 
     342                    $text = sprintf('%d', $arcresult->year); 
     343                    $after = ' ('.$arcresult->posts.')' . $afterafter; 
     344                } else { 
     345                    $text = sprintf('%d', $arcresult->year); 
     346                } 
     347                echo get_archives_link($url, $text, $format, $before, $after); 
     348            } 
     349        }            
    335350    } elseif ( 'daily' == $type ) { 
    336351        $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); 
Note: See TracChangeset for help on using the changeset viewer.