/**
Template Name: 文章模版
*/
get_header();
?>
>
<?php the_title();?>
$the_query = new WP_Query( 'posts_per_page=-1&ignore_sticky_posts=1' );
$year=0; $mon=0; $i=0; $j=0;
$all = array();
$output = '';
while ( $the_query->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;
?>
一键复制
编辑
Web IDE
原始数据
按行查看
历史