-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle-spet_merchant.php
More file actions
349 lines (232 loc) · 9.65 KB
/
single-spet_merchant.php
File metadata and controls
349 lines (232 loc) · 9.65 KB
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<?php
/**
* The template for displaying single Merchant custom post type
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package Shop_Petaluma
*/
get_header();
?>
<main id="primary" class="site-main">
<?php
while ( have_posts() ) :
the_post();
$merchant_id = get_the_ID(); // also used below for neighbors
// https://wordpress.stackexchange.com/questions/130947/get-term-slug-of-current-post
$terms = get_the_terms( $post->ID, 'zones' );
if ( !empty( $terms ) ){
// get the first term
$term = array_shift( $terms );
// echo $term->slug;
}
$categories = get_the_category();
if ( ! empty( $categories ) ) {
$category = $categories[0]->name ;
}
?>
<!-- <div class="title-section-wrapper">
<div class="title-container container">
<p class="content-type-name">Shops</p>
<p class="spet-subhead">By Categories</p>
</div>
</div> -->
<div class="category-bar-wrapper">
<div class="category-bar-container container">
<p class="category-name"><?php echo $category; ?></p>
</div>
</div>
<div class="content-wrapper">
<div class="content-container container">
<?php
// $term = get_query_var( 'medium' );
// $term = 'Kentucky';
$logo = get_field('merchant_logo');
$primary_products = get_field('primary_products');
$services = get_field('merchant_services');
$discounts = get_field('merchant_discounts');
$address = get_field('merchant_address');
$hours = get_field('merchant_hours');
$phone = get_field('merchant_phone');
$email = get_field('merchant_email');
$website = get_field('merchant_website');
$website_label = get_field('merchant_website_label');
if(!$website_label) { $website_label = get_field('merchant_website'); }
$socials = get_field('social_media');
$merchant_image = get_field('merchant_display_image');
?>
<?php if ($merchant_image) : ?>
<div class="merchant-image-mob">
<div class="merchant-image-wrapper" style="background-image: url(<?php echo $merchant_image; ?> )"></div>
</div>
<?php endif; ?>
<div class="row">
<div class="col-lg-2">
<?php if ( $logo ) : ?>
<div class="merchant-logo-wrapper merchant-logo-desk">
<img src="<?php echo $logo; ?>" alt="<?php the_title(); ?> Logo">
</div>
<?php endif; ?>
</div>
<div class="col-lg-10 merchant-info-wrapper">
<div class="row">
<div class="col-12">
<h1><?php the_title(); ?></h1>
<?php if ($primary_products) { ?>
<p class="merchant-subhead"><?php the_field('primary_products'); ?></p>
<?php } ?>
<p class="merchant-description"><?php the_field('merchant_description'); ?></p>
<?php if ($services) { ?>
<p class="merchant-label">Current Services / Restrictions</p>
<p><?php the_field('merchant_services'); ?></p>
<?php } ?>
<?php if ($discounts) { ?>
<p class="merchant-label">Discount Offerings</p>
<p><?php the_field('merchant_discounts'); ?></p>
<?php } ?>
<?php if ($services || $discounts) { ?>
<div class="merchant-nap-border"></div>
<?php } ?>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<?php if ($address) { ?>
<p class="merchant-label">Address</p>
<p><?php the_field('merchant_address'); ?></p>
<?php } ?>
<?php if ($hours) { ?>
<p class="merchant-label">Hours</p>
<p><?php the_field('merchant_hours'); ?></p>
<?php } ?>
<?php if ($socials) { ?>
<p class="merchant-label">Connect</p>
<div class="merchant-socials-wrapper">
<?php if( have_rows('social_media') ): ?>
<?php while( have_rows('social_media') ): the_row();
$social_icon = get_sub_field('social_icon');
$social_url = get_sub_field('social_url');
$fa_icon = 'fa-facebook-square';
if ($social_icon == 'facebook') { $fa_icon = 'fa-facebook-square'; }
if ($social_icon == 'twitter') { $fa_icon = 'fa-twitter-square'; }
if ($social_icon == 'instagram') { $fa_icon = 'fa-instagram'; }
if ($social_icon == 'youtube') { $fa_icon = 'fa-youtube'; }
if ($social_icon == 'yelp') { $fa_icon = 'fa-yelp-square'; }
?>
<?php if( $social_url ): ?>
<a href="<?php echo $social_url; ?>" target="_blank" rel="noreferrer"><i class="fa <?php echo $fa_icon; ?>"></i></a>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php } ?>
</div>
<div class="col-sm-6">
<?php if ($phone) { ?>
<p class="merchant-label">Phone</p>
<p><a href="tel:<?php the_field('merchant_phone'); ?>"><?php the_field('merchant_phone'); ?></a></p>
<?php } ?>
<?php if ($email) { ?>
<p class="merchant-label">email</p>
<p class="shrink-me-15"><a href="mailto:<?php the_field('merchant_email'); ?>"><?php the_field('merchant_email'); ?></a></p>
<?php } ?>
<?php if ($website) { ?>
<p class="merchant-label">website</p>
<p class="shrink-me-15"><a href="<?php the_field('merchant_website'); ?>" target="_blank" rel="noreferrer"><?php echo $website_label; ?></a></p>
<?php } ?>
</div>
</div>
<?php if ($merchant_image) { ?>
<div class="row merchant-image-desk">
<div class="col-sm-12">
<div class="merchant-image-wrapper" style="background-image: url(<?php echo $merchant_image; ?> )"></div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
<div class="merchant-share-wrapper">
<div class="merchant-share-container container">
<div class="merchant-share-website-wrapper">
<?php if ($website) { ?>
<a href="<?php the_field('merchant_website'); ?>" target="_blank" rel="noreferrer">Visit the <?php the_title(); ?> website</a>
<?php } ?>
</div>
<div class="merchant-share-icons-wrapper">
<span>SHARE </span>
<?php // echo do_shortcode('[DISPLAY_ULTIMATE_SOCIAL_ICONS]'); ?>
<?php echo do_shortcode('[addtoany buttons="facebook,twitter,email"]'); ?>
<!-- <a href="https://facebook.com" target="_blank" rel="noreferrer"><i class="fa fa-facebook-square"></i></a> -->
<!-- <a href="https://twitter.com" target="_blank" rel="noreferrer"><i class="fa fa-twitter-square"></i></a> -->
<!-- <a href="https://instagram.com" target="_blank" rel="noreferrer"><i class="fa fa-instagram"></i></a> -->
<!-- <a href="https://facebook.com" target="_blank" rel="noreferrer"><i class="fa fa-envelope"></i></a> -->
</div>
</div>
</div>
<div class="neighbors-wrapper">
<div class="container">
<h2>Meet our neighbors <?php // echo $term; ?> </h2>
<p class="spet-subhead"><?php echo $term->name ?></p>
</div>
<div class="neighbors container">
<div class="row">
<?php
$spet_neighbors_args = array(
'post_type' => 'spet_merchant',
'order' => 'DESC',
'orderby' => 'rand',
'posts_per_page' => 7,
'tax_query' => array(
array(
'taxonomy' => 'zones',
'field' => 'slug',
'terms' => $term,
),
),
);
$neighbors_counter = 0;
$spet_neighbors = new WP_Query( $spet_neighbors_args );
if ( $spet_neighbors->have_posts() ) {
while ( $spet_neighbors->have_posts() ) {
$spet_neighbors->the_post();
$current_id = get_the_ID();
if ($merchant_id != $current_id && $neighbors_counter < 6) {
$neighbors_counter++;
$spet_neighbors_cats = get_the_category();
if ( ! empty( $spet_neighbors_cats ) ) {
$neighbor_cat = $spet_neighbors_cats[0]->name ;
}
// $neighbor_logo = get_field('merchant_logo');
// $neighbor_description = get_field('merchant_description');
$neighbor_image = get_field('merchant_display_image');
?>
<div class="neighbor-merchant-card col-md-6 col-lg-4">
<a href="<?php the_permalink(); ?>">
<div class="neighbor-merchant-container" style="background-image: url(<?php echo $neighbor_image; ?>);">
<span class="neighbor-merchant-card-info-wrapper">
<p class="home-merchant-category"><?php echo $neighbor_cat; ?></p>
<h3><?php the_title(); ?></h3>
</span>
</div>
</a>
</div>
<?php
} // endif for kill current id
} // endwhile for neighbors
} else {
echo '<p>No merchants have been found.</p>';
};
wp_reset_postdata();
?>
</div>
</div>
</div>
<?php
endwhile; // End of the loop.
?>
</main><!-- #main -->
<?php
// get_sidebar();
get_footer();