/ Published in: PHP
                    
                                        created by Adi Dragus
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 /*-----------------------------------------------------------------------------------------------*/ /* GET MONTHLY ARCHIVE DIVIDED TO YEARS */ /*-----------------------------------------------------------------------------------------------*/ /* * splits: * <h3>$Year</h3> * <ul> * <li><a>$MonthName</a> $Number posts</li> * </ul> */ function get_by_year($sql, $args) { global $wpdb; return $sql .= $wpdb->prepare(" AND YEAR(`post_date`) = '%s'", $args['year']); } function get_archive_by_year() { $archiveString = wp_get_archives('type=yearly&echo=0'); foreach ($matches[1] as $year): echo "<h3>" . $year . "</h3>"; add_filter('getarchives_where', "get_by_year" , 666, 2); $monthlyArchives = preg_replace('#(.+)(\s\d{4})(</.+>)#', "$1 $3", wp_get_archives("type=monthly&echo=0&show_post_count=1&year=$year")); echo "<ul>" . $monthlyArchives . "</ul>"; remove_filter('getarchives_where', 666); endforeach; }
Comments
                    Subscribe to comments
                
                