-
Notifications
You must be signed in to change notification settings - Fork 3
/
page-events.php
182 lines (141 loc) · 3.38 KB
/
page-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
<?php
/**
* Template Name: Events
*
* This template is used to display
* latest Events Posts
*
* @package MITLibraries-News
* @since 1.0
*/
$pageRoot = getRoot( $post );
$section = get_post( $pageRoot );
$isRoot = $section->ID == $post->ID;
get_header(); ?>
<?php get_template_part( 'inc/sub-header' ); ?>
<div class="container container-fluid">
<?php
$date = DateTime::createFromFormat( 'Ymd', get_field( 'event_date' ) );
/*
* The event sort is two-fold:
* 1) Events today and into the future, sorted closest-first
* 2) Events yesterday and into the past, sorted closest-first
*/
$future = array(
'posts_per_page' => -1,
'ignore_sticky_posts' => true,
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'is_event',
'value' => '1',
'compare' => '=',
),
array(
'key' => 'event_date',
'value' => date( 'Y-m-d' ),
'compare' => '>=',
'type' => 'DATE',
),
),
'meta_key' => 'event_date',
'orderby' => array(
'meta_value_num' => 'ASC',
),
);
$the_future = new WP_Query( $future );
$future_posts = (array) $the_future->posts;
$past = array(
'posts_per_page' => 9,
'ignore_sticky_posts' => true,
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'is_event',
'value' => '1',
'compare' => '=',
),
array(
'key' => 'event_date',
'value' => date( 'Y-m-d' ),
'compare' => '<',
'type' => 'DATE',
),
),
'meta_key' => 'event_date',
'orderby' => array(
'meta_value_num' => 'DESC',
),
);
$the_past = new WP_Query( $past );
$past_posts = (array) $the_past->posts;
// Archived events tagged by "oldevents".
$archive = array(
'posts_per_page' => 9,
'ignore_sticky_posts' => true,
'post_type' => 'post',
'tag' => 'oldevents',
'orderby' => 'post_date',
);
$the_archive = new WP_Query( $archive );
$archive_posts = (array) $the_archive->posts;
?>
<div class="row">
<h1 class="events-header">Upcoming classes & events</h1>
<?php
if ( count( $future_posts ) > 0 ) {
$i = -1;
foreach ( $future_posts as $post ) {
$i++;
renderEventCard( $i, $post );
}
} else {
?>
<p class="left-padder">There are no upcoming classes or events at this time, but check back often.</p>
<?php
}
?>
</div> <!-- close row for upcoming events-->
<hr class="hidden-xs" />
<h2 class="padding-header">Past classes & events</h2>
<div class="row">
<?php
if ( count( $past_posts ) > 0 ) {
$i = -1;
foreach ( $past_posts as $post ) {
$i++;
renderEventCard( $i, $post );
}
}
?>
</div> <!-- close row for past events -->
<?php if ( count( $past_posts ) > 8 ) {
get_template_part( 'inc/more-posts' );
} ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
</div>
<!-- #primary -->
<script type="text/javascript">
$(document).ready(function() {
var offset = 11;
var limit = 9;
//$j("#postContainer").load("/news/add-posts-events/");
$("#another").click(function(){
limit = limit+9;
offset = offset+11;
$("#postContainer")
//.slideUp()
.load("/news/add-posts-events/?offset=1&limit="+limit, function() {
//.load("/news/test/?offset="+offset, function() {
$(this).slideDown();
//$j("#another").remove();
//$j(".moreBtn").html(' No More Posts') // if there are none left
$('.moreBtn').length;
});
return false;
});
});
</script>
<div class="container container-fluid">
<?php
get_footer();