|
8 | 8 |
|
9 | 9 | namespace Mitlib\Child;
|
10 | 10 |
|
11 |
| -get_header( 'child' ); |
| 11 | +// Define the queries which will populate the three display sections. |
| 12 | +$current = array( |
| 13 | + 'posts_per_page' => 10, |
| 14 | + 'ignore_sticky_posts' => false, |
| 15 | + 'post_type' => 'exhibits', // Only query exhibits. |
| 16 | + 'meta_key' => 'start_date', // Load up the event_date meta. |
| 17 | + 'orderby' => 'start_date', |
| 18 | + 'order' => 'DESC', // Descending, so later events first. |
| 19 | + 'meta_query' => array( // The meta_query is an array of query items. |
| 20 | + array( |
| 21 | + 'key' => 'start_date', // Which meta to query. |
| 22 | + 'value' => gmdate( 'Y-m-d' ), // Value for comparison. |
| 23 | + 'compare' => '<=', // Method of comparison. |
| 24 | + 'type' => 'DATE', |
| 25 | + ), |
| 26 | + array( |
| 27 | + 'relation' => 'OR', |
| 28 | + array( |
| 29 | + 'key' => 'end_date', // Which meta to query. |
| 30 | + 'value' => gmdate( 'Y-m-d' ), // Value for comparison. |
| 31 | + 'compare' => '>=', // Method of comparison. |
| 32 | + 'type' => 'DATE', |
| 33 | + ), |
| 34 | + array( |
| 35 | + 'key' => 'end_date', // Which meta to query. |
| 36 | + 'value' => '', // Value for comparison. |
| 37 | + 'compare' => '=', // Method of comparison. |
| 38 | + 'type' => 'CHAR', |
| 39 | + ), |
| 40 | + ), |
| 41 | + ), // End meta_query array. |
| 42 | +); // End current query. |
| 43 | + |
| 44 | +$future = array( |
| 45 | + 'post_type' => 'exhibits', // Only query exhibits. |
| 46 | + 'meta_key' => 'start_date', // Load up the event_date meta. |
| 47 | + 'orderby' => 'start_date', |
| 48 | + 'order' => 'ASC', |
| 49 | + 'posts_per_page' => 10, // Descending, so later events first. |
| 50 | + 'meta_query' => array( |
| 51 | + array( |
| 52 | + 'key' => 'start_date', // Which meta to query. |
| 53 | + 'value' => gmdate( 'Y-m-d' ), // Value for comparison. |
| 54 | + 'compare' => '>', // Method of comparison. |
| 55 | + 'type' => 'DATE', |
| 56 | + ), // The meta_query is an array of query items. |
| 57 | + ), // End meta_query array. |
| 58 | +); // End future query. |
| 59 | + |
| 60 | +$past = array( |
| 61 | + 'post_type' => 'exhibits', // Only query events. |
| 62 | + 'meta_key' => 'end_date', // Load up the event_date meta. |
| 63 | + 'orderby' => 'end_date', |
| 64 | + 'order' => 'DESC', // Descending, so later events first. |
| 65 | + 'posts_per_page' => 5, |
| 66 | + 'meta_query' => array( |
| 67 | + array( |
| 68 | + 'key' => 'end_date', // Which meta to query. |
| 69 | + 'value' => gmdate( 'Y-m-d' ), // Value for comparison. |
| 70 | + 'compare' => '<', // Method of comparison. |
| 71 | + 'type' => 'DATE', |
| 72 | + ), // The meta_query is an array of query items. |
| 73 | + ), // End meta_query array. |
| 74 | +); // End past query. |
| 75 | + |
12 | 76 | ?>
|
13 | 77 |
|
14 |
| - <?php get_template_part( 'inc/breadcrumbs', 'child' ); ?> |
| 78 | +<?php get_header( 'child' ); ?> |
| 79 | + |
| 80 | +<?php get_template_part( 'inc/breadcrumbs', 'child' ); ?> |
15 | 81 |
|
16 |
| - <div id="stage" class="inner" role="main"> |
| 82 | +<div id="stage" class="inner" role="main"> |
17 | 83 |
|
18 | 84 | <?php get_template_part( 'inc/title-banner' ); ?>
|
19 | 85 |
|
20 |
| - <div id="content" class="content has-sidebar"> |
| 86 | + <div id="content" class="content has-sidebar"> |
21 | 87 |
|
22 |
| - <div class="main-content"> |
23 |
| - |
24 |
| - <?php |
25 |
| - |
26 |
| - $current_query = new \WP_Query( |
27 |
| - array( |
28 |
| - 'posts_per_page' => 10, |
29 |
| - 'ignore_sticky_posts' => false, |
30 |
| - 'post_type' => 'exhibits', // Only query exhibits. |
31 |
| - 'meta_key' => 'start_date', // Load up the event_date meta. |
32 |
| - 'orderby' => 'start_date', |
33 |
| - 'order' => 'DESC', // Descending, so later events first. |
34 |
| - 'meta_query' => array( // The meta_query is an array of query items. |
35 |
| - array( |
36 |
| - 'key' => 'start_date', // Which meta to query. |
37 |
| - 'value' => gmdate( 'Y-m-d' ), // Value for comparison. |
38 |
| - 'compare' => '<=', // Method of comparison. |
39 |
| - 'type' => 'DATE', |
40 |
| - ), |
41 |
| - array( |
42 |
| - 'relation' => 'OR', |
43 |
| - array( |
44 |
| - 'key' => 'end_date', // Which meta to query. |
45 |
| - 'value' => gmdate( 'Y-m-d' ), // Value for comparison. |
46 |
| - 'compare' => '>=', // Method of comparison. |
47 |
| - 'type' => 'DATE', |
48 |
| - ), |
49 |
| - array( |
50 |
| - 'key' => 'end_date', // Which meta to query. |
51 |
| - 'value' => '', // Value for comparison. |
52 |
| - 'compare' => '=', // Method of comparison. |
53 |
| - 'type' => 'CHAR', |
54 |
| - ), |
55 |
| - ), |
56 |
| - ), // End meta_query array. |
57 |
| - ) // End array. |
58 |
| - ); // Close WP_Query constructor call. |
59 |
| - ?> |
| 88 | + <div class="main-content"> |
| 89 | + |
| 90 | + <?php $current_query = new \WP_Query( $current ); ?> |
60 | 91 |
|
61 | 92 | <div class="exhibits-feed-section">
|
62 | 93 |
|
63 | 94 | <h3 class="title-sub">Current Exhibits</h3>
|
64 |
| - |
| 95 | + |
65 | 96 | <?php
|
66 |
| - if ( $current_query->have_posts() ) : |
67 |
| - while ( $current_query->have_posts() ) : |
| 97 | + if ( $current_query->have_posts() ) { |
| 98 | + while ( $current_query->have_posts() ) { |
68 | 99 | $current_query->the_post(); // Loop for current exhibits.
|
69 | 100 |
|
70 | 101 | get_template_part( 'inc/exhibits-detail' );
|
| 102 | + }; |
| 103 | + wp_reset_postdata(); |
| 104 | + } else { |
| 105 | + echo '<p>There are no current exhibit announcements at this time. New exhibits are added throughout the year, so please check back.</p>'; |
| 106 | + } |
| 107 | + ?> |
71 | 108 |
|
72 |
| - endwhile; |
73 |
| - |
74 |
| - wp_reset_postdata(); |
75 |
| - |
76 |
| - else : |
77 |
| - ?> |
78 |
| - |
79 |
| - <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> |
80 |
| - |
81 |
| - <?php endif; ?> |
82 |
| - |
83 | 109 | </div>
|
84 | 110 |
|
85 |
| - <!-- END OF CURRENT EXHIBITS LOOP --> |
86 |
| - |
| 111 | + <!-- END OF CURRENT EXHIBITS LOOP --> |
87 | 112 |
|
88 |
| - <?php |
| 113 | + <?php $future_query = new \WP_Query( $future ); ?> |
89 | 114 |
|
90 |
| - $future_query = new \WP_Query( |
91 |
| - array( |
92 |
| - 'post_type' => 'exhibits', // Only query exhibits. |
93 |
| - 'meta_key' => 'start_date', // Load up the event_date meta. |
94 |
| - 'orderby' => 'start_date', |
95 |
| - 'order' => 'ASC', |
96 |
| - 'posts_per_page' => 10, // Descending, so later events first. |
97 |
| - 'meta_query' => array( |
98 |
| - array( |
99 |
| - 'key' => 'start_date', // Which meta to query. |
100 |
| - 'value' => gmdate( 'Y-m-d' ), // Value for comparison. |
101 |
| - 'compare' => '>', // Method of comparison. |
102 |
| - 'type' => 'DATE', |
103 |
| - ), // The meta_query is an array of query items. |
104 |
| - ), // End meta_query array. |
105 |
| - ) // End array. |
106 |
| - ); // Close WP_Query constructor call. |
107 |
| - ?> |
108 |
| - |
109 | 115 | <div class="exhibits-feed-section">
|
110 |
| - |
| 116 | + |
111 | 117 | <h3 class="title-sub">Upcoming Exhibits</h3>
|
112 |
| - |
| 118 | + |
113 | 119 | <?php
|
114 |
| - if ( $future_query->have_posts() ) : |
115 |
| - while ( $future_query->have_posts() ) : |
| 120 | + if ( $future_query->have_posts() ) { |
| 121 | + while ( $future_query->have_posts() ) { |
116 | 122 | $future_query->the_post(); // Loop for future exhibits.
|
117 | 123 |
|
118 | 124 | get_template_part( 'inc/exhibits-detail' );
|
119 |
| - |
120 |
| - endwhile; |
121 |
| - |
| 125 | + }; |
122 | 126 | wp_reset_postdata();
|
| 127 | + } else { |
| 128 | + echo '<p>There are no upcoming exhibit announcements at this time. New exhibits are added throughout the year, so please check back.</p>'; |
| 129 | + } |
| 130 | + ?> |
123 | 131 |
|
124 |
| - else : |
125 |
| - ?> |
126 |
| - |
127 |
| - <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> |
128 |
| - |
129 |
| - <?php endif; ?> |
130 |
| - |
131 | 132 | </div>
|
132 |
| - |
133 |
| - |
| 133 | + |
134 | 134 | <!-- END OF UPCOMING EXHIBITS LOOP -->
|
135 |
| - |
136 |
| - |
137 |
| - <?php |
138 |
| - |
139 |
| - $past_query = new \WP_Query( |
140 |
| - array( |
141 |
| - 'post_type' => 'exhibits', // Only query events. |
142 |
| - 'meta_key' => 'end_date', // Load up the event_date meta. |
143 |
| - 'orderby' => 'end_date', |
144 |
| - 'order' => 'DESC', // Descending, so later events first. |
145 |
| - 'posts_per_page' => 5, |
146 |
| - 'meta_query' => array( |
147 |
| - array( |
148 |
| - 'key' => 'end_date', // Which meta to query. |
149 |
| - 'value' => gmdate( 'Y-m-d' ), // Value for comparison. |
150 |
| - 'compare' => '<', // Method of comparison. |
151 |
| - 'type' => 'DATE', |
152 |
| - ), // The meta_query is an array of query items. |
153 |
| - ), // End meta_query array. |
154 |
| - ) // End array. |
155 |
| - ); // Close WP_Query constructor call. |
156 |
| - ?> |
| 135 | + |
| 136 | + <?php $past_query = new \WP_Query( $past ); ?> |
157 | 137 |
|
158 | 138 | <div class="exhibits-feed-section">
|
159 |
| - |
| 139 | + |
160 | 140 | <h3 class="title-sub">Past Exhibits</h3>
|
161 |
| - |
| 141 | + |
162 | 142 | <?php
|
163 |
| - while ( $past_query->have_posts() ) : |
| 143 | + while ( $past_query->have_posts() ) { |
164 | 144 | $past_query->the_post(); // Loop for events.
|
165 | 145 |
|
166 | 146 | get_template_part( 'inc/exhibits-detail' );
|
167 |
| - |
168 |
| - wp_reset_postdata(); // Restore global post data stomped by the_post(). |
169 |
| - |
170 |
| - endwhile; // End of the loop. |
| 147 | + }; |
| 148 | + wp_reset_postdata(); // Restore global post data stomped by the_post(). |
171 | 149 | ?>
|
172 | 150 |
|
173 | 151 | </div>
|
174 | 152 |
|
175 | 153 | <a class="button-secondary exhibits-button" href="/exhibits/past-exhibits/">View all past exhibits</a>
|
176 | 154 |
|
177 | 155 | <!-- END OF PAST EXHIBITS LOOP -->
|
178 |
| - |
179 |
| - |
180 |
| - |
181 |
| - </div> <!-- main-content --> |
182 |
| - |
183 |
| - <?php get_sidebar(); ?> |
184 |
| - |
185 |
| - </div> <!-- content --> |
186 |
| - |
187 |
| - </div> <!-- stage --> |
188 |
| - |
| 156 | + |
| 157 | + </div> <!-- .main-content --> |
| 158 | + |
| 159 | + <?php get_sidebar(); ?> |
| 160 | + |
| 161 | + </div> <!-- #content --> |
| 162 | + |
| 163 | +</div> <!-- #stage --> |
| 164 | + |
189 | 165 | <?php get_footer(); ?>
|
0 commit comments