-
Notifications
You must be signed in to change notification settings - Fork 0
/
archives.php
34 lines (34 loc) · 968 Bytes
/
archives.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/*
Template Name: 文章归档
*/
?>
<?php get_header(); ?>
<h1 class="title"><?php the_title();?></h1>
<div class="content">
<?php
$previous_year = $year = 0;
$previous_month = $month = 0;
$ul_open = false;
$myposts = get_posts('numberposts=-1&orderby=post_date&order=DESC');
foreach($myposts as $post) :
setup_postdata($post);
$year = mysql2date('Y', $post->post_date);
$month = mysql2date('n', $post->post_date);
$day = mysql2date('j', $post->post_date);
if($year != $previous_year || $month != $previous_month) :
if($ul_open == true) :
echo '</ul>';
endif;
echo '<h3>'; echo the_time('Y年m月'); echo '</h3>';
echo '<ul>';
$ul_open = true;
endif;
$previous_year = $year; $previous_month = $month;
?>
<li>
<time datetime="<?php the_time('Y年m月d日');?>"><?php the_time('m-d');?></time> · <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</div>
<?php get_footer(); ?>