'', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => true, 'echo' => 1 ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); if ( '' != $limit ) { $limit = absint($limit); $limit = ' LIMIT '.$limit; } // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride $archive_date_format_over_ride = 0; // options for daily archive (only if you over-ride the general date format) $archive_day_date_format = 'Y/m/d'; // options for weekly archive (only if you over-ride the general date format) $archive_week_start_date_format = 'Y/m/d'; $archive_week_end_date_format = 'Y/m/d'; if ( !$archive_date_format_over_ride ) { $archive_day_date_format = get_option('date_format'); $archive_week_start_date_format = get_option('date_format'); $archive_week_end_date_format = get_option('date_format'); } //filters $where = apply_filters('customarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r ); $join = apply_filters('customarchives_join', "", $r); $output = '
    '; $count = 0; $txt = array(); $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit"; $key = md5($query); $cache = wp_cache_get( 'wp_custom_archive' , 'general'); if ( !isset( $cache[ $key ] ) ) { $arcresults = $wpdb->get_results($query); $cache[ $key ] = $arcresults; wp_cache_set( 'wp_custom_archive', $cache, 'general' ); } else { $arcresults = $cache[ $key ]; } if ( $arcresults ) { $afterafter = $after; foreach ( (array) $arcresults as $arcresult ) { $url = get_month_link( $arcresult->year, $arcresult->month ); /* translators: 1: month name, 2: 4-digit year */ $text = sprintf(__('%s'), $wp_locale->get_month($arcresult->month)); $year_text = sprintf('
    %d
    ', $arcresult->year); //if ( $show_post_count ) //$after = ' ('.$arcresult->posts.')' . $afterafter; // only display the text year when it is a new year if ($arcresult->year != $temp_year) { // it's a new year, so print out all the months if there are any if ($txt) { $output .= "
  • "; $rows = count($txt) / 3; $r_count = 1; for ($i=0; $i $rows) { $output .= ""; $r_count = 1;} $output .= $txt[$i]; $output .= "
    "; $r_count = $r_count + 1; } $output .= "

  • "; unset($txt); } $output .= "
  • $year_text
  • "; } $before = ""; $after = " ($arcresult->posts)"; $temp_txt = get_archives_link($url, $text, 'html', $before, $after); $temp_txt = str_replace("
  • ", "", $temp_txt); $txt[] = str_replace("
  • ", "", $temp_txt); $temp_year = $arcresult->year; } } if ($txt) { $output .= "
  • "; $rows = count($txt) / 3; $r_count = 1; for ($i=0; $i $rows) { $output .= ""; $r_count = 1;} $output .= $txt[$i]; $output .= "
    "; $r_count = $r_count + 1; } $output .= "
  • "; } $output .= '
'; echo $output; ?>