-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.php
154 lines (127 loc) · 6.27 KB
/
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
<?php /* Template Name: Händelser */ ?>
<?php get_header(); ?>
<div class="gde-page-outer-wrapper">
<div class="gde-targeted-pages-navigation-wrapper">
<?php wp_nav_menu( array( "theme_location" => "target-meny-sidor", "container_class" => "gde-target-pages-navigation-list" ) ); ?>
</div>
<div class="gde-breadcrumbs-wrapper">
<p><a href="<?php echo home_url(); ?>">Hem</a> / <?php the_title(); ?></p>
</div>
<div class="gde-page-wrapper">
<div class="gde-page-content">
<h1><?php the_title(); ?></h3>
<h2 class="gde-page-events-upcoming">Kommande händelser</h2>
<?php
$date_now = date('Ymd', strtotime("now"));
$date_future = date('Ymd', strtotime("+24 months"));
$upcoming_args = array(
'post_type' => 'events',
'posts_per_page' => -1,
'meta_key' => 'end_date',
'meta_compare' => 'BETWEEN',
'meta_type' => 'numeric',
'meta_value' => array($date_now, $date_future),
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
$past_args = array(
'post_type' => 'events',
'posts_per_page' => -1,
'meta_key' => 'end_date',
'meta_compare' => 'NOT BETWEEN',
'meta_type' => 'numeric',
'meta_value' => array($date_now, $date_future),
'orderby' => 'meta_value_num',
'order' => 'DESC'
);
// the upcoming events query
$upcoming_query = new WP_Query( $upcoming_args );
// the past events query
$past_query = new WP_Query( $past_args );
?>
<?php if ( $upcoming_query->have_posts() ) : ?>
<?php while ( $upcoming_query->have_posts() ) : $upcoming_query->the_post(); ?>
<?php
$startDate = get_field('start_date');
$endDate = get_field('end_date');
?>
<div class="gde-page-events-module-row-wrapper">
<div class="gde-page-events-module-row row">
<div class="gde-page-events-module-col col-lg-3">
<div class="gde-page-events-left-date">
<p><?php if ( $startDate === $endDate) {
echo $startDate;
} else if ($startDate !== $endDate && !strncmp($startDate, $endDate)) {
echo $startDate .'-'. $endDate;
} ?></p>
</div>
</div>
<div class="gde-page-events-module-col col-lg-6">
<div class="gde-page-events-middle-title">
<a href="<?php the_field('page_url'); ?>">
<div class="gde-page-events-module-title">
<h4><?php the_title(); ?></h4>
</div>
</a>
</div>
</div>
<div class="gde-page-events-module-col col-lg-2">
<div class="gde-page-events-right-info">
<p><span>Plats:</span> <?php the_field('location');?></p>
<p><span>Målgrupp:</span> <?php the_field('audience');?></p>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( 'Just nu har vi inga uppkommande händelser, kom tillbaks senare!' ); ?></p>
<?php endif; ?>
<h2 class="gde-page-events-upcoming">Tidigare händelser</h2>
<?php if ( $past_query->have_posts() ) : ?>
<?php while ( $past_query->have_posts() ) : $past_query->the_post(); ?>
<?php
$startDate = get_field('start_date');
$endDate = get_field('end_date');
?>
<div class="gde-page-events-module-row-wrapper">
<div class="gde-page-events-module-row row">
<div class="gde-page-events-module-col col-lg-3">
<div class="gde-page-events-left-date">
<p><?php if ( $startDate === $endDate) {
echo $startDate;
} else if ($startDate !== $endDate && !strncmp($startDate, $endDate)) {
echo $startDate .'-'. $endDate;
} ?></p>
</div>
</div>
<div class="gde-page-events-module-col col-lg-4">
<div class="gde-page-events-middle-title">
<a href="<?php the_field('page_url'); ?>">
<div class="gde-page-events-module-title">
<h4><?php the_title(); ?></h4>
</div>
</a>
</div>
</div>
<div class="gde-page-events-module-col col-lg-3">
<div class="gde-page-events-right-info">
<p><span>Plats:</span> <?php the_field('location');?></p>
<p><span>Målgrupp:</span> <?php the_field('audience');?></p>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( 'Det finns inga tidigare händelser!' ); ?></p>
<?php endif; ?>
</div>
</div>
<a href="<?php echo home_url(); ?>">
<div class="gde-back-to-page"><img src="<?php bloginfo('template_directory'); ?>/assets/icons/long-arrow-left-light.svg" class="back-icon" /><p>Tillbaka till startsidan</p></div>
</a>
</div>
<?php get_footer(); ?>