-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate-home.php
323 lines (244 loc) · 9.1 KB
/
template-home.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<?php /* Template Name: Homepage */ get_header(); ?>
<main class="main" role="main">
<?php
$post_types = lawreview_get_post_types();
// set up arguments
$posts = get_posts(array(
'posts_per_page' => 1,
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => 138, // 138 is the Featured id
),
),
));
?>
<?php if ( $posts ): ?>
<section class="hero is-primary">
<div class="hero-body">
<div class="container">
<?php foreach( $posts as $post ) : setup_postdata( $post );
$label = $post_types[get_field('ilr_post_type')];
$subtitle = get_field('ilr_subtitle');
$author = get_field('ilr_author');
$citation = get_field('ilr_citation');
?>
<article class="post featured">
<!-- label -->
<?php if ( !empty($label) ) : ?>
<span class="tag is-primary"><?=$label?></span>
<?php endif; ?>
<!-- title -->
<h1 class="title is-1"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<!-- subtitle -->
<?php if ( !empty($subtitle) ) : ?>
<h2 class="subtitle is-3"><?=$subtitle?></h2>
<?php endif; ?>
<!-- meta -->
<div class="post-meta">
<!-- meta: author -->
<?php if ( !empty($author) ) : ?>
<span class="author">by <?=$author?></span>
<?php endif; ?>
<!-- meta: citation -->
<?php if ( !empty($citation) ) : ?>
<span class="citation"><?=$citation?></span>
<?php endif; ?>
</div>
</article>
<?php endforeach; ?>
</div>
</div>
</section>
<?php endif;?>
<section class="section">
<div class="container">
<div class="columns">
<!-- COLUMN: Print posts -->
<div class="column is-9-tablet is-8-desktop main-content">
<?php
$posts = get_posts( array(
'post_type' => 'post',
'posts_per_page' => 6,
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => 36
// 36 is the Print id
// 10 is the Online id
),
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => 138, // 138 is the Featured id
'operator' => 'NOT IN'
),
),
'meta_query' => array(
array(
'key' => 'ilr_post_type',
'value' => 'note',
'compare' => '!='
),
),
));
?>
<?php if( $posts ):
foreach( $posts as $post ) : setup_postdata( $post );
$label = $post_types[get_field('ilr_post_type')];
$subtitle = get_field('ilr_subtitle');
$author = get_field('ilr_author');
$citation = get_field('ilr_citation');
?>
<article class="post">
<!-- label -->
<?php if ( !empty($label) ) : ?>
<span class="tag is-primary"><?=$label?></span>
<?php endif; ?>
<!-- title -->
<h2 class="title is-3"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<!-- subtitle -->
<?php if ( !empty($subtitle) ) : ?>
<h3 class="subtitle is-4"><?=$subtitle?></h3>
<?php endif; ?>
<!-- meta -->
<div class="post-meta">
<!-- meta: author -->
<?php if ( !empty($author) ) : ?>
<span class="author">by <?=$author?></span>
<?php endif; ?>
<!-- meta: citation -->
<?php if ( !empty($citation) ) : ?>
<span class="citation"><?=$citation?></span>
<?php endif; ?>
</div>
</article>
<?php endforeach; ?>
<?php else: ?>
<article class="post">
<h2 class="title is-3">Nothing to display</h2>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
</article>
<?php endif; ?>
</div>
<!-- COLUMN: Online -->
<div class="column is-3-tablet is-2-desktop sidebar online">
<span class="label">Online</span>
<?php
$posts = get_posts( array(
'posts_per_page' => 10,
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => 10, // 10 is the Online id
),
),
));
?>
<?php if( $posts ):
foreach( $posts as $post ) : setup_postdata( $post );
$label = $post_types[get_field('ilr_post_type')];
$subtitle = get_field('ilr_subtitle');
// like strip_tags() only removes content too
// we do this to remove star footnote
$author = preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', get_field('ilr_author'));
$citation = get_field('ilr_citation');
?>
<article class="post">
<!-- meta: date -->
<div class="post-meta">
<span class="date"><time datetime="<?php the_time('Y-m-d'); ?>"><?php echo get_the_date(); ?></time></span>
</div>
<!-- title -->
<h4 class="title is-6"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<!-- meta: author -->
<?php if ( !empty($author) ) : ?>
<div class="post-meta">
<span class="author">by <?=$author?></span>
</div>
<?php endif; ?>
</article>
<?php endforeach; ?>
<?php else: ?>
<article class="post">
<h2 class="title is-3">Nothing to display</h2>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
</article>
<?php endif; ?>
</div>
<!-- COLUMN: News, Popular -->
<div class="column is-hidden-touch is-2-desktop sidebar news">
<!-- News -->
<span class="label">News</span>
<?php
$posts = get_posts( array(
'posts_per_page' => 5,
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => 8, // 8 is the News id
),
),
));
?>
<?php if( $posts ):
foreach( $posts as $post ) : setup_postdata( $post );
?>
<article class="post">
<!-- meta: date -->
<div class="post-meta">
<span class="date"><time datetime="<?php the_time('Y-m-d'); ?>"><?php echo get_the_date(); ?></time></span>
</div>
<!-- title -->
<h4 class="title is-6"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
</article>
<?php endforeach; ?>
<?php else: ?>
<article class="post">
<h2 class="title is-3">Nothing to display</h2>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
</article>
<?php endif; ?>
<!-- Popular Posts -->
<span class="label">Popular</span>
<?php
$popular = new WP_Query( array(
'posts_per_page' => 5,
'meta_key' => 'popular_posts',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => array( 36, 10 ),
),
),
));
?>
<?php while ($popular->have_posts()) : $popular->the_post(); ?>
<article class="post">
<!-- meta: date -->
<div class="post-meta">
<span class="date"><time datetime="<?php the_time('Y-m-d'); ?>"><?php echo get_the_date(); ?></time></span>
</div>
<!-- title -->
<h4 class="title is-6"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
</article>
<?php endwhile; wp_reset_postdata(); ?>
</div>
</div>
</div>
</section>
</main>
<?php get_footer(); ?>