-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive-events.php
51 lines (41 loc) · 1.49 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
<?php get_header(); ?>
<div class="bodycontainer">
<div class="container">
<?php
$posts = get_posts(array(
'post_type' => 'events',
'posts_per_page' => -1,
'meta_key' => 'date',
'orderby' => 'meta_value',
'order' => 'ASC',
));
$today = date('Ymd');
$allevents = get_query_var('allevents', false);
if ($allevents) : ?>
<div class="eventtoggle">
<a href="<?php echo remove_query_arg('allevents') ?>">Hide past events</a>
</div>
<?php else: ?>
<div class="eventtoggle">
<a href="<?php echo add_query_arg(array('allevents' => 'true')) ?>">Show past events</a>
</div>
<?php endif; ?>
<div class="spacer50"></div>
<?php if ($posts): ?>
<?php foreach ($posts as $post): setup_postdata($post); ?>
<?php if ($allevents || get_field('date') >= $today ): ?>
<div class="post">
<h1 class="title"><?php $date = get_field("date"); echo substr($date,6,2) . "/" . substr($date,4,2) . "/" . substr($date,0,4) . " - "; the_title(); ?></h1>
<div class="postmeta">
<p>Location: <a href="<?php the_field("location_website")?>"><?php the_field("location") ?></a></p>
<p>Event page: <a href="<?php the_field("event_website")?>">Link</a></p>
</div>
<div class="postcontent">
<?php the_content(); ?>
</div>
</div>
<?php endif; ?>
<?php endforeach; wp_reset_postdata(); endif; ?>
</div>
</div>
<?php get_footer(); ?>