forked from kangabell/boston-hassle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfront-page.php
304 lines (256 loc) · 8.55 KB
/
front-page.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
<?php
/*
Template Name: Homepage
*/
?>
<?php
$featured_ids = get_field('featured_posts', false, false);
$cat_1 = get_field('cat_1');
$cat_2 = get_field('cat_2');
$cat_3 = get_field('cat_3');
$picture_cat = get_field('picture_cat');
$cta_img = get_field('cta_img');
if ( !empty( $cta_img ) ) {
$cta_bg = esc_url($cta_img['url']);
} else {
$cta_bg = get_template_directory_uri() . '/library/img/texture-blue.jpg';
}
$cta2_img = get_field('cta2_img');
if ( !empty( $cta2_img ) ) {
$cta2_bg = esc_url($cta2_img['url']);
} else {
$cta2_bg = get_template_directory_uri() . '/library/img/texture-lt.jpg';
}
?>
<?php include 'header.php'; ?>
<main>
<div class="primary">
<div class="hero">
<?php // first Featured Post
$args = array(
'posts_per_page' => 1,
'post__in' => $featured_ids,
'orderby' => 'post__in',
'ignore_sticky_posts' => true
);
query_posts ($args);
if (have_posts()) : while (have_posts()) : the_post();
?>
<article class="hero"><a href="<?php the_permalink(); ?>">
<div class="image">
<div class="thumbnail">
<?php the_post_thumbnail('large'); ?>
</div>
</div>
<div class="text">
<?php get_template_part('partials/date-category'); ?>
<h3><?php echo short_title(); ?></h3>
<?php
// use a custom excerpt if there is one, or if not use the subtitle,
// and if there's neither, use the automatic excerpt
if ( has_excerpt() ) {
the_excerpt();
} elseif ( get_field('subtitle') ) {
echo '<p class="excerpt">';
the_field('subtitle');
echo '</p>';
} else {
the_excerpt();
}
?>
<p class="meta"><?php echo get_the_author(); ?></p>
</div>
</a></article>
<?php
endwhile; endif;
wp_reset_query();
?>
</div>
<div class="events">
<h2>Hassle Picks</h2>
<?php // upcoming events in the Chosen Shows category
$events = tribe_get_events( array(
'posts_per_page' => 5,
'start_date' => current_time( 'Y-m-d' ), // upcoming
'tax_query' => array(
array(
'taxonomy' => 'tribe_events_cat',
'field' => 'slug',
'terms' => 'chosen-shows',
)
)
) );
foreach ( $events as $post ) {
setup_postdata( $post );
?>
<article>
<p class="meta">
<?php echo tribe_events_event_schedule_details(); ?>
<?php if ( tribe_get_cost() ) : ?>
<span class="tribe-events-cost"><?php echo tribe_get_cost( null, true ) ?></span>
<?php endif; ?>
</p>
<h3><a href="<?php echo esc_url( tribe_get_event_link() ); ?>"><?php the_title(); ?></a></h3>
<p class="meta category"><?php echo tribe_get_venue(); ?></p>
</article>
<?php } wp_reset_postdata(); ?>
<a class="view-all" href="<?php echo tribe_get_events_link(); ?>">View All</a>
</div>
</div> <!-- end .primary -->
<div class="secondary">
<?php // 2 more Featured Posts
$args = array(
'posts_per_page' => 2,
'post__in' => $featured_ids,
'orderby' => 'post__in',
'ignore_sticky_posts' => true,
'offset' => 1
);
query_posts ($args);
if (have_posts()) : while (have_posts()) : the_post();
include 'partials/article.php';
endwhile; endif;
wp_reset_query();
?>
<div class="home-widget-1">
<?php dynamic_sidebar( 'home_widget-1' ); ?>
</div>
</div>
<div class="tertiary">
<?php // 2 more Featured Posts
$args = array(
'posts_per_page' => 2,
'post__in' => $featured_ids,
'orderby' => 'post__in',
'ignore_sticky_posts' => true,
'offset' => 3
);
query_posts ($args);
if (have_posts()) : while (have_posts()) : the_post();
include 'partials/article.php';
endwhile; endif;
wp_reset_query();
?>
</div>
<div class="home-pencil-1">
<?php dynamic_sidebar( 'home_pencil-1' ); ?>
</div>
<div>
<?php
// Category #1
$category = $cat_1;
$class = 'category-1';
include(locate_template('partials/category-section.php'));
?>
<?php
// Category #2
$category = $cat_2;
$class = 'category-2';
include(locate_template('partials/category-section.php'));
?>
<?php
// Category #3
$category = $cat_3;
$class = 'category-3';
include(locate_template('partials/category-section.php'));
?>
</div>
<div class="articles">
<div>
<?php // General stream of articles
$loop = new WP_Query( array(
'posts_per_page'=>8,
'ignore_sticky_posts'=>true,
'post__not_in' => $featured_ids, // exclude featured posts, since they've already appeared above
'category__not_in' => $picture_cat->term_id// exclude, since this has its own bigger section
) );
while ($loop->have_posts()) :
$class = 'default';
$loop->the_post();
include 'partials/article.php';
endwhile; wp_reset_postdata();
?>
</div>
</div>
<div class="home-pencil-2">
<?php dynamic_sidebar( 'home_pencil-2' ); ?>
</div>
<div>
<!-- Category Section with Pictures -->
<div class="<?php echo $picture_cat->slug ?> picture-cat category">
<h2><?php echo $picture_cat->name; ?></h2>
<div>
<?php
$loop = new WP_Query( array(
'posts_per_page'=> 6,
'ignore_sticky_posts'=>true,
'cat'=>$picture_cat->term_id
) );
while ($loop->have_posts()) :
$loop->the_post();
?>
<article><a href="<?php echo get_permalink(); ?>">
<div class="thumbnail" style="background-image: url('<?php bhass_article_img(); ?>')"></div>
<h3><?php echo short_title(); ?></h3>
<p class="meta"><?php echo get_the_author(); ?></p>
</a></article>
<?php
endwhile; wp_reset_postdata();
?>
</div>
<a class="view-all" href="<?php echo get_category_link( $picture_cat->term_id ); ?>">View All <?php echo $picture_cat->name; ?></a>
<div class="home-leaderboard">
<?php dynamic_sidebar( 'home_leaderboard' ); ?>
</div>
</div>
<div class="home-widget-2">
<?php dynamic_sidebar( 'home_widget-2' ); ?>
</div>
</div>
<div class="donate cta" style="background-image: url('<?php echo $cta_bg; ?>');">
<a href="<?php the_field('cta_link'); ?>">
<?php if ( get_field('cta_heading') ) : ?>
<h2>
<?php the_field('cta_heading'); ?>
</h2>
<?php endif; ?>
<?php if ( get_field('cta_text') ) : ?>
<p class="h3">
<?php the_field('cta_text'); ?>
</p>
<?php endif; ?>
</a>
</div>
<div class="articles">
<div>
<?php // General stream of articles, continued
$loop = new WP_Query( array(
'posts_per_page'=>8,
'ignore_sticky_posts'=>true,
'offset' => 8,
'post__not_in' => $featured_ids,
'category__not_in' => $picture_cat->term_id
) );
while ($loop->have_posts()) :
$class = 'default';
$loop->the_post();
include 'partials/article.php';
endwhile; wp_reset_postdata();
?>
</div>
</div>
<div class="newsletter cta" style="background-image: url('<?php echo $cta2_bg; ?>');">
<?php if ( get_field('cta2_text') ) : ?>
<p class="h4">
<?php the_field('cta2_text'); ?>
</p>
<?php endif; ?>
<?php if ( get_field('cta2_heading') ) : ?>
<h2 class="h1">
<?php the_field('cta2_heading'); ?>
</h2>
<?php endif; ?>
<a href="<?php the_field('cta2_link'); ?>" class="button large"><?php the_field('cta2_link-text'); ?></a>
</div>
</main>
<?php get_footer(); ?>