WordPress.org

Make WordPress Core

Ticket #2352: template-functions-general.php.diff

File template-functions-general.php.diff, 1.5 KB (added by stewart, 8 years ago)

Patch to add yearly archive type

  • template-functions-general.php

     
    344344                                echo get_archives_link($url, $text, $format, $before, $after); 
    345345                        } 
    346346                } 
     347        } elseif ('yearly' == $type) { 
     348         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date ASC" . $limit); 
     349        if ($arcresults) { 
     350            $afterafter = $after; 
     351            foreach ($arcresults as $arcresult) { 
     352                        $url  = get_settings('home').'/'.$arcresult->year; 
     353                if ($show_post_count) { 
     354                    $text = sprintf('%d', $arcresult->year); 
     355                    $after = '&nbsp;('.$arcresult->posts.')' . $afterafter; 
     356                } else { 
     357                    $text = sprintf('%d', $arcresult->year); 
     358                } 
     359                echo get_archives_link($url, $text, $format, $before, $after); 
     360            } 
     361                }                        
    347362        } elseif ( 'daily' == $type ) { 
    348363                $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_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
    349364                if ( $arcresults ) {