-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpage-timeline.php
117 lines (98 loc) · 2.74 KB
/
page-timeline.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* The template for displaying a Timeline.
*
* @package StormBringer
* @since StormBringer 0.0.1
*
* Template Name: Timeline
*/
?>
<?php get_header(); ?>
<?php //get_sidebar(); ?>
<div id="content" role="main">
<?php
/**
* stormbringer_content_before hook.
*
* @hooked stormbringer_breadcrumb - 10
*/
do_action( 'stormbringer_content_before' );
?>
<?php if ( have_posts() ) : the_post(); ?>
<?php
get_template_part( 'content', 'page' );
?>
<?php endif; ?>
<section class="timeline-content">
<?php query_posts( 'posts_per_page=-1' );
$dates_array = Array();
$year_array = Array();
$i = 0;
$prev_post_ts = null;
$prev_post_year = null;
$distance_multiplier = 9;
?>
<?php while (have_posts()) :
the_post();
$post_ts = strtotime( $post->post_date );
$post_year = date( 'Y', $post_ts );
/* Handle the first year as a special case */
if (is_null( $prev_post_year )) {
?>
<h3 class="archive-year"><?php echo $post_year ?></h3>
<ul class="archives-list">
<?php
}
else if ($prev_post_year != $post_year) {
/* Close off the OL */
?>
</ul>
<?php
$working_year = $prev_post_year;
/* Print year headings until we reach the post year */
while ( $working_year > $post_year ) {
$working_year --;
?>
<h3 class="archive-year"><?php echo $working_year ?></h3>
<?php
}
/* Open a new ordered list */
?>
<ul class="archives-list">
<?php
}
/* Compute difference in days */
if ( ! is_null( $prev_post_ts ) && $prev_post_year == $post_year ) {
$dates_diff = ( date( 'z', $prev_post_ts ) - date( 'z', $post_ts ) ) * $distance_multiplier;
} else {
$dates_diff = 0;
}
?>
<li><span class="date"><?php the_time( __( 'F j\<\s\u\p\>S\<\/\s\u\p\>', 'stormbringer' ) ); ?></span>
<span class="linked"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></span>
<?php if ( get_comments_number() != 0 ): ?>
<span class="badge"><?php comments_popup_link( __( '0', 'stormbringer' ), __( '1', 'stormbringer' ), __( '%', 'stormbringer' ) ); ?></span>
<?php endif; ?>
</li>
<?php
/* For subsequent iterations */
$prev_post_ts = $post_ts;
$prev_post_year = $post_year;
endwhile;
/* If we've processed at least *one* post, close the ordered list */
if ( ! is_null( $prev_post_ts )) {
?>
</ul>
<?php } ?>
</section>
<!-- /.timeline-content -->
<?php
/**
* stormbringer_content_after hook.
*/
do_action( 'stormbringer_content_after' );
?>
</div>
<!-- /#content -->
<?php get_footer(); ?>