>

have_posts() ) : $the_query->the_post(); $year_tmp = get_the_time('Y'); $mon_tmp = get_the_time('n'); $y=$year; $m=$mon; if ($mon != $mon_tmp && $mon > 0) $output .= '
'; if ($year != $year_tmp) { // 输出年份 $year = $year_tmp; $all[$year] = array(); } if ($mon != $mon_tmp) { // 输出月份 $mon = $mon_tmp; array_push($all[$year], $mon); $output .= "

$year-$mon

"; } $output .= '
'; endwhile; wp_reset_postdata(); $output .= '
'; echo $output; ?>