-
Notifications
You must be signed in to change notification settings - Fork 1
/
page-exhibits-rotch-library.php
190 lines (143 loc) · 5.23 KB
/
page-exhibits-rotch-library.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
<?php
/**
* Template Name: Exhibits | Rotch Library
*
* @package MIT_Libraries_Child
* @since Twenty Twelve 1.0
*/
get_header( 'child' );
?>
<?php get_template_part( 'inc/breadcrumbs', 'child' ); ?>
<div id="stage" class="inner" role="main">
<?php get_template_part( 'inc/postHead' ); ?>
<div id="content" class="content has-sidebar">
<div class="main-content">
<?php
$current_query = new WP_Query(
array(
'post_type' => 'exhibits', // Only query exhibits.
'posts_per_page' => 10,
'ignore_sticky_posts' => false,
'meta_key' => 'start_date',
'orderby' => 'start_date',
'order' => 'DESC', // Descending, so later events first.
'meta_query' => array(
array(
'key' => 'start_date', // Which meta to query.
'value' => gmdate( 'Y-m-d' ), // Value for comparison.
'compare' => '<=', // Method of comparison.
'type' => 'DATE',
),
array(
'key' => 'end_date', // Which meta to query.
'value' => gmdate( 'Y-m-d' ), // Value for comparison.
'compare' => '>=', // Method of comparison.
'type' => 'DATE',
),
array(
'key' => 'location', // Which meta to query.
'value' => 'Rotch Library', // Value for comparison.
'compare' => '=', // Method of comparison.
'type' => 'CHAR',
), // The meta_query is an array of query items.
), // End meta_query array.
) // End array.
); // Close WP_Query constructor call.
?>
<div class="exhibits-feed-section">
<h3 class="title-sub">Current Exhibits</h3>
<?php
if ( $current_query->have_posts() ) :
while ( $current_query->have_posts() ) :
$current_query->the_post(); // Loop for current exhibits.
get_template_part( 'inc/exhibits-detail' );
endwhile;
wp_reset_postdata();
else :
?>
<p><?php esc_html_e( 'There are no current exhibit announcements at this time. New exhibits are added throughout the year, so please check back.' ); ?></p>
<?php endif; ?>
</div>
<!-- END OF CURRENT EXHIBITS LOOP -->
<?php
$future_query = new WP_Query(
array(
'post_type' => 'exhibits', // Only query exhibits.
'meta_key' => 'start_date',
'posts_per_page' => 10,
'orderby' => 'start_date',
'order' => 'ASC', // Descending, so later events first.
'meta_query' => array(
array(
'key' => 'start_date', // Which meta to query.
'value' => gmdate( 'Y-m-d' ), // Value for comparison.
'compare' => '>', // Method of comparison.
'type' => 'DATE',
),
array(
'key' => 'location', // Which meta to query.
'value' => 'Rotch Library', // Value for comparison.
'compare' => '=', // Method of comparison.
'type' => 'CHAR',
), // The meta_query is an array of query items.
), // End meta_query array.
) // End array.
); // Close WP_Query constructor call.
?>
<div class="exhibits-feed-section">
<h3 class="title-sub">Upcoming Exhibits</h3>
<?php
if ( $future_query->have_posts() ) :
while ( $future_query->have_posts() ) :
$future_query->the_post(); // Loop for future exhibits.
get_template_part( 'inc/exhibits-detail' );
endwhile;
wp_reset_postdata();
else :
?>
<p><?php esc_html_e( 'There are no upcoming exhibit announcements at this time. New exhibits are added throughout the year, so please check back.' ); ?></p>
<?php endif; ?>
</div>
<!-- END OF UPCOMING EXHIBITS LOOP -->
<?php
$past_query = new WP_Query(
array(
'post_type' => 'exhibits', // Only query exhibits.
'meta_key' => 'end_date',
'posts_per_page' => 5,
'orderby' => 'end_date',
'order' => 'DESC', // Descending, so later events first.
'meta_query' => array(
array(
'key' => 'end_date', // Which meta to query.
'value' => gmdate( 'Y-m-d' ), // Value for comparison.
'compare' => '<', // Method of comparison.
'type' => 'DATE',
),
array(
'key' => 'location', // Which meta to query.
'value' => 'Rotch Library', // Value for comparison.
'compare' => '=', // Method of comparison.
'type' => 'CHAR',
), // The meta_query is an array of query items.
), // End meta_query array.
) // End array.
); // Close WP_Query constructor call.
?>
<div class="exhibits-feed-section">
<h3 class="title-sub">Past Exhibits</h3>
<?php
while ( $past_query->have_posts() ) :
$past_query->the_post(); // Loop for events.
get_template_part( 'inc/exhibits-detail' );
wp_reset_postdata(); // Restore global post data stomped by the_post().
endwhile; // End of the loop.
?>
</div>
<!-- END OF UPCOMING EXHIBITS LOOP -->
<a class="button-secondary exhibits-button" href="/exhibits/past-exhibits/">View all past exhibits</a>
</div> <!-- main-content -->
<?php get_sidebar(); ?>
</div> <!-- content -->
</div> <!-- stage -->
<?php get_footer(); ?>