-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_archive.php
77 lines (65 loc) · 2.45 KB
/
test_archive.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/*
* Template Name: Simple Way Archive Test
* @author: Bluest
* @Blog : http://bluest.me
*/
?>
<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/style/archive.min.css">
<?php get_header();?>
<div class="main">
<div class="content clear">
<div class="post left-column">
<div class="archive card">
<div class="archives-content">
<div class="title">
<h1>文章归档</h1>
<span class="bg"></span>
</div>
<div class="archive-time-line">
<?php
$previous_year = $year = 0;
$previous_month = $month = 0;
$ul_open = false;
$all_post = get_posts('numberposts=-1&orderby=post_date&order=DESC');
$psots_array = array();
foreach ($all_post as $post) {
$year = mysql2date('Y', $post->post_date);
$month = mysql2date('n', $post->post_date);
$day = mysql2date('j', $post->post_date);
$psots_array[$year][$month] = $post;
}
foreach($all_post as $post) {
$year = mysql2date('Y', $post->post_date);
$month = mysql2date('n', $post->post_date);
$day = mysql2date('j', $post->post_date);
if ( $year != $previous_year ) {
echo "<div class=\"year\"><h2>"; the_time('Y'); echo "</h2></div>";
}
if ( $month != $previous_month ) {
echo "<div class=\"month\"><h3>"; the_time('m'); echo "月</h3></div>";
}
$previous_month = $month;
$previous_year = $year;
?>
<div class="article-lists">
<span class="day"><?php the_time('d'); ?></span>
<a class="article-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<a class="comments" href="<?php comments_link(); ?>" title="查看 <?php the_title(); ?> 的评论"><?php echo get_comments_number(); ?></a>
</div>
<?php } ?>
</div>
</div>
</div><!-- Archieve Ends -->
</div><!-- Post Ends -->
<aside class="aside right-column"><!-- Right Aside Begain -->
<?php get_sidebar();?>
</aside><!-- Right Aside Ends -->
</div><!-- Content Ends -->
</div><!-- Main Ends -->
<!-- Footer Begain -->
<?php get_footer(); ?>
<!-- Footer Ends -->
</div><!-- Wrap Ends -->
</body>
</html>