-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive-events.php
349 lines (241 loc) · 13.5 KB
/
archive-events.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<?php
/**
* Inperspective Records
*
* Developed by Simon van Stipriaan
* http://svs.design
*
*
*/
get_header(); ?>
<div class="ajax-container" data-barba="container" data-barba-namespace="archive-events">
<article class="container grid">
<section id="upcoming-events" class="archive">
<?php
$now = current_time( 'timestamp' ); // Get current unix timestamp
$hour = 24;
$today = strtotime($hour . ':00:00');
$tendaysago = strtotime('-10 day', $today);
$yesterday = strtotime('-1 day', $today);
$tommorow = strtotime('+1 day', $today);
$dayaftertommorow = strtotime('+2 day', $today);
$tendayslater = strtotime('+10 day', $today);
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$upcomingarg = array (
'post_type' => 'events', // your event post type slug
'post_status' => 'publish', // only show published events
//'orderby' => 'meta_value', // order by date
//'meta_key' => 'event_start', // your ACF Date & Time Picker field
//'meta_value' => $now, // Use the current time from above
//'meta_compare' => '>=', // Compare today's datetime with our event datetime
'order' => 'ASC', // Show earlier events last
'posts_per_page' => 24, // because, divisible by 1, 2 and 3 (ensuring all breakpoint designs)
'paged' => $paged,
// 'orderby' => 'date',
'orderby' => 'meta_value',
'meta_key' => 'event_start_date',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'event_start_date',
'compare' => '>=', // starts after or equal
'value' => $now
),
array(
'key' => 'event_end_date',
'compare' => '<=', // starts before or equal
'value' => '9999999999'
)
),
);
$upcoming_events_query = new WP_Query( $upcomingarg );
//remove_filter( 'get_meta_sql', 'get_meta_sql_date', 10, 2 ); ?>
<?php if ( $upcoming_events_query->have_posts() ) : ?>
<?php $countevents = 0; ?>
<div class="event-items">
<div class="page-title-positioner outer-grid-item outer-grid-item-sm-6 sticky">
<div class="page-titler">
<span class="inner">
Events
</span><!-- inner -->
</div> <!--.page-title -->
</div><!-- .page-title-position -->
<?php
// the loop
while ( $upcoming_events_query->have_posts() ) : $upcoming_events_query->the_post();
include(locate_template('content-events.php')); ?>
<?php endwhile; ?>
</div><!--event -items -->
<div class="page-nav container">
<?php global $upcoming_events_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $upcoming_events_query->max_num_pages,
'prev_next' =>true,
// 'format' => '/page/%#%',
// 'current' => $current_page,
// 'total' => $total_pages,
// 'type' => 'list',
'prev_text' => '<svg version="1.1" class="svg-icon rs_arrow_left" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve"><g class="arrow_left"><polygon points="50,49.667 50,0 0,24.667"/></g></svg>',
'next_text' => '<svg version="1.1" class="svg-icon rs_arrow_right" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="10px" height="10px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve"><g class="arrow_right"><polygon points="0,0 0,49.667 50,25"/></g></svg>'
//'prev_text' => '<div class="hoverlink"><div class="svg-icon hover-icon arrow-left" data-path-hover="M0,6.5L11 0 11 13 0 6.5 0 6.5z"> <svg width="100%" height="100%" xmlns:svg="http://www.w3.org/2000/svg" version="1.0" xml:space="preserve" width="11px" height="13px" viewBox="0 0 11 13"> <path d="M0,6L11 6 11 7 0 7 0 6.5z" class="arrow_right_path" fill="#000" /> </svg> </div><span>Previous</span></div>',
//'next_text' => '<div class="hoverlink"><div class="svg-icon hover-icon arrow-right" data-path-hover="M11,6.5L0 13 0 0 11 6.5 11 6.5z"> <svg width="100%" height="100%" xmlns:svg="http://www.w3.org/2000/svg" version="1.0" xml:space="preserve" width="11px" height="13px" viewBox="0 0 11 13"> <path d="M11,7L0 7 0 6 11 6 11 6.5z" class="arrow_right_path" fill="#000" /></svg></div><span>Next</span></div>',
) );
?>
</div> <!-- ".page-nav" -->
<?php
// clean up after the query and pagination
wp_reset_postdata(); ?>
<?php else: ?>
<?php //_e( 'Sorry, no events' );
//include a random image of a previous event
$randomimagearg = array (
'post_type' => 'events', // your event post type slug
'post_status' => 'publish', // only show published events
//'orderby' => 'meta_value', // order by date
//'meta_key' => 'event_start', // your ACF Date & Time Picker field
//'meta_value' => $now, // Use the current time from above
//'meta_compare' => '>=', // Compare today's datetime with our event datetime
// 'order' => 'ASC', // Show earlier events last
'posts_per_page' => 1, // because, divisible by 1, 2 and 3 (ensuring all breakpoint designs)
// 'paged' => $paged,
'orderby' => 'rand'
);
$random_image_query = new WP_Query( $randomimagearg );?>
<?php if ($random_image_query->have_posts() ) : ?>
<div class="event-items">
<div class="page-title-positioner outer-grid-item outer-grid-item-sm-6 sticky">
<div class="page-titler">
<span class="inner">
Events
</span><!-- inner -->
</div> <!--.page-title -->
</div><!-- .page-title-position -->
<?php while ( $random_image_query->have_posts() ) : $random_image_query->the_post();
$randomposterart = get_field('poster_art'); // image
?>
<div id="random-event-details" class="grid random-event">
<?php// if($posterart): ?>
<div class="cover-image-item outer-grid-item outer-grid-item-sm-8" style="background-image: url('<?php echo $randomposterart;?>');">
</div><!-- image-item -->
<?php //endif; //$posterart ?>
</div>
<?php endwhile; ?>
</div><!--event -items -->
<?php endif; //$posterart ?>
<?php
// clean up after the randomn image query
wp_reset_postdata();
//_e( 'Sorry, no events' );
endif; ?>
<?php wp_reset_query(); //reset: $upcoming_events_query ?>
</section><!-- -->
<section id="past-events" class="outer-grid-item inner outer-grid-item-sm-6">
<?php
$now = current_time( 'timestamp' ); // Get current unix timestamp
$hour = 24;
$today = strtotime($hour . ':00:00');
$tendaysago = strtotime('-10 day', $today);
$yesterday = strtotime('-1 day', $today);
$tommorow = strtotime('+1 day', $today);
$dayaftertommorow = strtotime('+2 day', $today);
$tendayslater = strtotime('+10 day', $today);
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$pastarg = array (
'post_type' => 'events', // your event post type slug
'post_status' => 'publish', // only show published events
//'orderby' => 'meta_value', // order by date
//'meta_key' => 'event_start', // your ACF Date & Time Picker field
//'meta_value' => $now, // Use the current time from above
//'meta_compare' => '>=', // Compare today's datetime with our event datetime
'order' => 'DESC', // Show later events last
'posts_per_page' => 24, // because, divisible by 1, 2 and 3 (ensuring all breakpoint designs)
'paged' => $paged,
// 'orderby' => 'date',
'orderby' => 'meta_value',
'meta_key' => 'event_start_date',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'event_start_date',
'compare' => '>=', // starts after or equal
'value' => '0000000000' //$now //'0000000000
),
array(
'key' => 'event_end_date',
'compare' => '<=', // starts before or equal
'value' => $now//'9999999999'
)
),
);
$past_events_query = new WP_Query( $pastarg );
//remove_filter( 'get_meta_sql', 'get_meta_sql_date', 10, 2 ); ?>
<?php if ( $past_events_query->have_posts() ) : ?>
<?php $countevents = 0; ?>
<div class="past-event-title">
Past Events
</div>
<div class="event-items">
<?php
// the loop
while ( $past_events_query->have_posts() ) : $past_events_query->the_post();
//start get fields
/* $eventstart = get_field('event_start_date'); // date and time picker
$eventend = get_field('event_end_date'); // date and time picker
$posterart = get_field('poster_art'); // image
$venue = get_field('venue'); // text
// $artists = get_field('artists_playing'); // relationship / change to post object?
$ticketprice = get_field('event_ticket_price'); //text
$description = get_field('event_description'); // text area
$fblink = get_field('facebook_link'); //text
$ralink = get_field('resident_advisor_link'); //text
*/
$eventid = get_the_ID();
$upcomingeventid = $eventid;
$isupcomingnextevent = get_post_meta($upcomingeventid, 'is-next-event' ); // if 'true' in array
$isupcomingevent = get_post_meta($eventid, 'is-upcoming-event' ); // if 'true' in array
//end get fields
foreach($isupcomingevent as $isupcomingeven){
// echo "is upcoming event? ";
// echo $isupcomingeven;
};
include(locate_template('content-events.php')); ?>
<?php endwhile; ?>
</div><!--event -items -->
<div class="page-nav container">
<?php global $past_events_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $past_events_query->max_num_pages,
'prev_next' =>true,
// 'format' => '/page/%#%',
// 'current' => $current_page,
// 'total' => $total_pages,
// 'type' => 'list',
'prev_text' => '<svg version="1.1" class="svg-icon rs_arrow_left" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve"><g class="arrow_left"><polygon points="50,49.667 50,0 0,24.667"/></g></svg>',
'next_text' => '<svg version="1.1" class="svg-icon rs_arrow_right" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="10px" height="10px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve"><g class="arrow_right"><polygon points="0,0 0,49.667 50,25"/></g></svg>'
//'prev_text' => '<div class="hoverlink"><div class="svg-icon hover-icon arrow-left" data-path-hover="M0,6.5L11 0 11 13 0 6.5 0 6.5z"> <svg width="100%" height="100%" xmlns:svg="http://www.w3.org/2000/svg" version="1.0" xml:space="preserve" width="11px" height="13px" viewBox="0 0 11 13"> <path d="M0,6L11 6 11 7 0 7 0 6.5z" class="arrow_right_path" fill="#000" /> </svg> </div><span>Previous</span></div>',
//'next_text' => '<div class="hoverlink"><div class="svg-icon hover-icon arrow-right" data-path-hover="M11,6.5L0 13 0 0 11 6.5 11 6.5z"> <svg width="100%" height="100%" xmlns:svg="http://www.w3.org/2000/svg" version="1.0" xml:space="preserve" width="11px" height="13px" viewBox="0 0 11 13"> <path d="M11,7L0 7 0 6 11 6 11 6.5z" class="arrow_right_path" fill="#000" /></svg></div><span>Next</span></div>',
) );
?>
</div> <!-- ".page-nav" -->
<?php
// clean up after the query and pagination
wp_reset_postdata(); ?>
<?php else: ?>
<div class="" style="">
<?php _e( 'Sorry, no events' ); ?>
</div>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
<?php wp_reset_query(); //reset: $past_events_query ?>
</section><!-- -->
</article> <!-- container -->
</div><!-- class="ajax-container" data-barba="container" data-barba-namespace -->
<?php get_footer(); ?>