-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·151 lines (145 loc) · 5.8 KB
/
index.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
/**
* The main template file
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package WP_Bootstrap_Starter
*/
get_header(); ?>
<?php // get all posts
$posts = get_posts(array(
'posts_per_page' => -1,
'orderby' => 'meta_value',
'meta_key' => 'start_date',
'order' => 'ASC'
));
$prev_divider = '';
$timelineDivider = get_theme_mod('timeline_customizer_divider','Decade');
if( $posts ):
?>
<div class="container-fluid">
<div class="row align-items-center justify-content-around" id="tag-viewport">
<div class="col-auto d-none d-md-block order-first">
<button type="button" class="btn btn-light px-3" id="previous-tag">
<span class="fas fa-chevron-left text-dark"></span>
<span class="sr-only">Previous tags</span>
</button>
</div>
<div class="col-auto d-none d-md-block order-last">
<button type="button" class="btn btn-light px-3" id="next-tag">
<span class="fas fa-chevron-right text-dark"></span>
<span class="sr-only">Next tags</span>
</button>
</div>
<div class="col overflow-hidden">
<div class="owl-carousel" id="tag-carousel">
<?php $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC')); ?>
<?php foreach ( $tags as $tag ) : ?>
<div class="tag p-2 bg-light small rounded d-inline-block">
<a href="<?php echo get_term_link($tag); ?>" class="text-dark">
<?php echo $tag->name; ?>
</a>
</div>
<?php endforeach; ?>
<?php $categories = get_categories(array('orderby' => 'count', 'order' => 'DESC')); ?>
<?php foreach ( $categories as $category ) : ?>
<div class="tag p-2 bg-light small rounded d-inline-block">
<a href="<?php echo get_term_link($category); ?>" class="text-dark">
<?php echo $category->name; ?>
</a>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<div class="row align-items-center" id="timeline-viewport">
<div class="owl-carousel" id="event-carousel">
<?php foreach ( $posts as $post ) : ?>
<?php
setup_postdata( $post );
if (get_post_meta( $post->ID, 'start_date', true )):
$start_year = date("Y", strtotime(get_post_meta( $post->ID, 'start_date', true )));
if ($timelineDivider == 'Decade'):
$current_divider = substr_replace($start_year,'0s',3);
elseif ($timelineDivider == 'Year'):
$current_divider = $start_year;
endif;
else:
$start_year = 'undated';
$current_divider = 'undated';
endif;
?>
<div class="card text-white shadow" data-dateStart="<?php echo $start_year; ?>" data-hash="<?php echo urlencode(the_title($before = '', $after = '', $echo = false)); ?>">
<?php if ( $current_divider != $prev_divider ) : ?>
<h2 class="decade text-dark font-italic"><?php echo $current_divider; ?></h2>
<?php endif; ?>
<?php if (has_post_thumbnail()) : ?>
<?php the_post_thumbnail( $size = 'post-thumbnail', array( 'class' => 'card-img' ) ); ?>
<?php else: ?>
<svg class="card-img" width="400px" height="400px" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Event image">
<title>Placeholder</title>
<rect width="100%" height="100%" fill="#868e96"></rect>
</svg>
<?php endif; ?>
<div class="card-img-overlay d-flex justify-content-center align-items-center rounded">
<h1 class="mb-0 text-center event-title text-break">
<a href="<?php echo get_permalink(); ?>" class="text-white">
<?php echo wp_trim_words(the_title($before = '', $after = '', $echo = false), 7); ?>
</a>
</h1>
<?php if (get_post_meta( $post->ID, 'start_date', true )): ?>
<p class="small event-date position-absolute mb-0">
<?php
if (get_post_meta( $post->ID, 'end_date', true )):
$end_year = date("Y", strtotime(get_post_meta( $post->ID, 'end_date', true )));
if ($start_year == $end_year):
echo date("F j", strtotime(get_post_meta( $post->ID, 'start_date', true ))) . ' - ' . date("F j, Y", strtotime(get_post_meta( $post->ID, 'end_date', true )));
else:
echo date("F j, Y", strtotime(get_post_meta( $post->ID, 'start_date', true ))) . ' - ' . date("F j, Y", strtotime(get_post_meta( $post->ID, 'end_date', true )));
endif;
else:
echo date("F j, Y", strtotime(get_post_meta( $post->ID, 'start_date', true )));
endif;
?>
</p>
<?php endif; ?>
</div>
</div>
<?php
if ($timelineDivider == 'Decade'):
$prev_divider = substr_replace($start_year,'0s',3);
elseif ($timelineDivider == 'Year'):
$prev_divider = $start_year;
endif;
?>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
</div>
</div>
<div class="row align-items-center justify-content-center py-3" id="slider-nav-viewport">
<div class="col-auto d-none d-md-block order-first">
<button type="button" class="btn btn-gold px-3 text-white" id="previous">
<span class="fas fa-chevron-left text-white"></span>
<span class="sr-only">Previous slide</span>
</button>
</div>
<div class="col-auto d-none d-md-block order-last">
<button type="button" class="btn btn-gold px-3 text-white" id="next">
<span class="fas fa-chevron-right text-white"></span>
<span class="sr-only">Next slide</span>
</button>
</div>
<div class="col mx-2 mx-md-0">
<div class="w-100" id="range-slider" aria-hidden="true"></div>
</div>
</div>
</div>
<?php endif; ?>
<?php
get_footer();