-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplate-timeline.php
98 lines (76 loc) · 2.75 KB
/
template-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
<?php
/*
Template Name: Timeline
*/
?>
<?php get_header(); ?>
<div id="content-wrap">
<div id="content" class="page col-full">
<?php if ( $woo_options[ 'woo_breadcrumbs_show' ] == 'true' ) woo_breadcrumbs(); ?>
<div id="main" class="col-left">
<?php $args = array( 'posts_per_page' => -1, 'post_type' => array( 'post', 'woo_video' ) ); query_posts( $args );
$dates_array = Array();
$year_array = Array();
$i = 0;
$prev_post_ts = null;
$prev_post_year = null;
$distance_multiplier = 9;
?>
<div class="post">
<h1 class="title"><?php the_title(); ?></h1>
<div id="archives" class="entry">
<?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'); ?><sup><?php the_time('S') ?></sup></span> <span class="linked"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></span> <span class="comments"><?php comments_popup_link(__('0 comments', 'woothemes'), __('1 comment', 'woothemes'), __('% comments', 'woothemes')); ?></span></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 } ?>
</div><!--entry-->
</div><!--post-->
</div><!-- /#main -->
<?php // wp_reset_query(); ?>
<?php get_sidebar(); ?>
</div><!-- /#content -->
</div><!-- /#content-wrap -->
<?php get_footer(); ?>