-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage-home.php
More file actions
361 lines (326 loc) · 17.3 KB
/
Copy pathpage-home.php
File metadata and controls
361 lines (326 loc) · 17.3 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
350
351
352
353
354
355
356
357
358
359
360
361
<?php
// Template Name: Página Inicial
?>
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<main class="page-content page-content--index">
<section class="banner flex flex--items-c flex--justify-c" style="background-image: url('<?php the_field('foto-banner') ?>');">
<div class="banner__search">
<form id="home-search">
<div class="flex flex--items-c">
<div>
<label for="categoria"><span class="sr-only">Finalidade</span></label>
<div class="custom-select" style="min-width:200px;">
<select name="categoria" id="categoria">
<option value="0">Finalidade</option>
<?php
$terms = get_terms('categoria_imoveis');
foreach ($terms as $term) { ?>
<option value="categoria=<?php echo $term->slug; ?>">
<?php echo $term->name; ?>
</option>
<?php } ?>
</select>
</div>
</div>
<div>
<label for="condicao"><span class="sr-only">Condição</span></label>
<div class="custom-select" style="min-width:200px;">
<select name="condicao" id="condicao">
<option value="0">Condição</option>
<?php
$terms = get_terms('condicao_imoveis');
foreach ($terms as $term) { ?>
<option value="condicao=<?php echo $term->slug; ?>">
<?php echo $term->name; ?>
</option>
<?php } ?>
</select>
</div>
</div>
<div>
<label for="tipo"><span class="sr-only">Tipo de imóvel</span></label>
<div class="custom-select" style="min-width:200px;">
<select name="tipo" id="tipo">
<option value="0">Tipo de imóvel</option>
<?php
$terms = get_terms('tipo_imoveis');
foreach ($terms as $term) { ?>
<option value="tipo=<?php echo $term->slug; ?>">
<?php echo $term->name; ?>
</option>
<?php } ?>
</select>
</div>
</div>
</div>
<button class="btn btn--bold" type="submit">Buscar</button>
</form>
</div>
</section>
<?php
$args = array(
'post_type' => 'imoveis',
'order' => 'DESC',
'posts_per_page' => 9,
'tax_query' => array(
array(
'taxonomy' => 'exibicao',
'field' => 'slug',
'terms' => 'destaque'
)
)
);
$the_query = new WP_Query ($args);
?>
<section class="container advert" style="margin-top: 70px; margin-bottom: 80px">
<div class="middlecontent">
<div class="innerTitle">
<h2 class="innerTitle__title innerTitle__title--middlecontent">Destaques</h2>
</div>
</div>
<div class="advert__list flex row gutter flex--wrap">
<?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post();
$termsArrayCategory = get_the_terms($post->ID, 'categoria_imoveis');
$termsSlugCategory = "";
$termsCategoryLabel = "";
foreach ($termsArrayCategory as $term) {
$termsSlugCategory .= $term->slug . ' ';
$termsCategoryLabel .= $term->slug . ' <span>e</span> ';
}
$termsArrayCondition = get_the_terms($post->ID, 'condicao_imoveis');
$termsSlugCondition = "";
foreach ($termsArrayCondition as $term) {
$termsSlugCondition .= $term->slug . ' ';
}
$termsArrayType = get_the_terms($post->ID, 'tipo_imoveis');
$termsSlugType = "";
foreach ($termsArrayType as $term) {
$termsSlugType .= $term->slug . ' ';
}
$exhibitionArray = get_the_terms($post->ID, 'exibicao');
$exhibition = "";
if ($exhibitionArray) {
foreach ($exhibitionArray as $item) {
$exhibition = $item->slug;
}
}
?>
<div class="col-4 col-sm-12 col-lg-6">
<div class="advert__item">
<div class="advert__top">
<div class="advert__badge"><?php echo $termsSlugCondition ?></div>
<?php if (trim(get_field('rent')) != 0 && trim(get_field('rent')) != "") { ?>
<div class="advert__badge advert__badge--right">
R$ <?php echo number_format(get_field('rent'), 2, ',', '.') ?> / mês
</div>
<?php } ?>
<?php if (trim(get_field('price')) != 0 && trim(get_field('price')) != "") { ?>
<div class="advert__badge advert__badge--right">
R$ <?php echo number_format(get_field('price'), 2, ',', '.') ?></div>
<?php } ?>
<div class="advert__img">
<img
src="<?php echo get_field('images')[0]["inner-image"] ?>"
alt="<?php the_title(); ?>">
</div>
<div class="advert__badge advert__badge--featured" title="Imóvel destaque">
<span class="fas fa-star"></span>
</div>
</div>
<div class="advert__bottom flex flex--col flex--justify-sb">
<div class="advert__location">
<p class="advert__category-container"><?php the_field('type') ?> para <span
class="advert__category"><?php echo $termsCategoryLabel ?></span></p>
<p class="advert__city-container">em <span class="advert__city"><?php the_field('city') ?></span>
</p>
</div>
<p class="advert__neighbourhood-container"><span class="fas fa-map-marker-alt advert__icon"></span>
<span
class="advert__neighbourhood"><?php the_field('neighbourhood') ?></span></p>
<ul class="advert__info flex flex--justify-sb flex--wrap">
<?php if (trim(get_field('dorms-quantity')) != "" && trim(get_field('dorms-quantity')) != 0) { ?>
<li class="advert__info-item flex flex--col flex--items-c">
<span
class="advert__icon advert__icon--big fas fa-bed flex flex--items-c flex--justify-c"></span>
<p class="advert__info-category">Dorms</p>
<p class="advert__info-quantity"><?php the_field('dorms-quantity') ?></p>
</li>
<?php } ?>
<?php if (trim(get_field('suites-quantity')) != "" && trim(get_field('suites-quantity')) != 0) { ?>
<li class="advert__info-item flex flex--col flex--items-c">
<span
class="advert__icon advert__icon--big fas fa-bath flex flex--items-c flex--justify-c"></span>
<p class="advert__info-category">Suítes</p>
<p class="advert__info-quantity"><?php the_field('suites-quantity') ?></p>
</li>
<?php } ?>
<?php if (trim(get_field('bathroom-quantity')) != "" && trim(get_field('bathroom-quantity')) != 0) { ?>
<li class="advert__info-item flex flex--col flex--items-c">
<span
class="advert__icon advert__icon--big fas fa-shower flex flex--items-c flex--justify-c"></span>
<p class="advert__info-category">Banheiros</p>
<p class="advert__info-quantity"><?php the_field('bathroom-quantity') ?></p>
</li>
<?php } ?>
<?php if (trim(get_field('area-quantity')) != "" && trim(get_field('area-quantity')) != 0) { ?>
<li class="advert__info-item flex flex--col flex--items-c">
<span
class="advert__icon advert__icon--big fas fa-th-large flex flex--items-c flex--justify-c"></span>
<p class="advert__info-category">Área</p>
<p class="advert__info-quantity"><?php the_field('area-quantity') ?>m²</p>
</li>
<?php } ?>
<?php if (trim(get_field('parking-quantity')) != "" && trim(get_field('parking-quantity')) != 0) { ?>
<li class="advert__info-item flex flex--col flex--items-c">
<span
class="advert__icon advert__icon--big fas fa-car flex flex--items-c flex--justify-c"></span>
<p class="advert__info-category">Vagas</p>
<p class="advert__info-quantity"><?php the_field('parking-quantity') ?></p>
</li>
<?php } ?>
</ul>
<a href="<?php the_permalink(); ?>" class="advert__button btn btn--bold btn--full btn--small">
Ver mais
</a>
</div>
</div>
</div>
<?php endwhile; else: endif; ?>
</div>
</section>
<?php wp_reset_postdata(); ?>
<?php
$args = array(
'post_type' => 'imoveis',
'order' => 'DESC',
'posts_per_page' => 6,
);
$the_query = new WP_Query ($args);
?>
<section class="container advert">
<div class="middlecontent">
<div class="innerTitle">
<h2 class="innerTitle__title innerTitle__title--middlecontent">Anúncios Recentes</h2>
<p class="innerTitle__text innerTitle__text--middlecontent">
<?php the_field('anuncios-recentes'); ?>
</p>
</div>
</div>
<div class="advert__list flex row gutter flex--wrap">
<?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post();
$termsArrayCategory = get_the_terms($post->ID, 'categoria_imoveis');
$termsSlugCategory = "";
$termsCategoryLabel = "";
foreach ($termsArrayCategory as $term) {
$termsSlugCategory .= $term->slug . ' ';
$termsCategoryLabel .= $term->slug . ' <span>e</span> ';
}
$termsArrayCondition = get_the_terms($post->ID, 'condicao_imoveis');
$termsSlugCondition = "";
foreach ($termsArrayCondition as $term) {
$termsSlugCondition .= $term->slug . ' ';
}
$termsArrayType = get_the_terms($post->ID, 'tipo_imoveis');
$termsSlugType = "";
foreach ($termsArrayType as $term) {
$termsSlugType .= $term->slug . ' ';
}
$exhibitionArray = get_the_terms($post->ID, 'exibicao');
$exhibition = "";
if ($exhibitionArray) {
foreach ($exhibitionArray as $item) {
$exhibition = $item->slug;
}
}
?>
<div class="col-4 col-sm-12 col-lg-6">
<div class="advert__item">
<div class="advert__top">
<div class="advert__badge"><?php echo $termsSlugCondition ?></div>
<?php if (trim(get_field('rent')) != 0 && trim(get_field('rent')) != "") { ?>
<div class="advert__badge advert__badge--right">
R$ <?php echo number_format(get_field('rent'), 2, ',', '.') ?> / mês
</div>
<?php } ?>
<?php if (trim(get_field('price')) != 0 && trim(get_field('price')) != "") { ?>
<div class="advert__badge advert__badge--right">
R$ <?php echo number_format(get_field('price'), 2, ',', '.') ?></div>
<?php } ?>
<div class="advert__img">
<img
src="<?php echo get_field('images')[0]["inner-image"] ?>"
alt="<?php the_title(); ?>">
</div>
<?php if ($exhibition == "destaque") { ?>
<div class="advert__badge advert__badge--featured" title="Imóvel destaque">
<span class="fas fa-star"></span>
</div>
<?php } ?>
</div>
<div class="advert__bottom flex flex--col flex--justify-sb">
<div class="advert__location">
<p class="advert__category-container"><?php the_field('type') ?> para <span
class="advert__category"><?php echo $termsCategoryLabel ?></span></p>
<p class="advert__city-container">em <span class="advert__city"><?php the_field('city') ?></span>
</p>
</div>
<p class="advert__neighbourhood-container"><span class="fas fa-map-marker-alt advert__icon"></span>
<span
class="advert__neighbourhood"><?php the_field('neighbourhood') ?></span></p>
<ul class="advert__info flex flex--justify-sb flex--wrap">
<?php if (trim(get_field('dorms-quantity')) != "" && trim(get_field('dorms-quantity')) != 0) { ?>
<li class="advert__info-item flex flex--col flex--items-c">
<span
class="advert__icon advert__icon--big fas fa-bed flex flex--items-c flex--justify-c"></span>
<p class="advert__info-category">Dorms</p>
<p class="advert__info-quantity"><?php the_field('dorms-quantity') ?></p>
</li>
<?php } ?>
<?php if (trim(get_field('suites-quantity')) != "" && trim(get_field('suites-quantity')) != 0) { ?>
<li class="advert__info-item flex flex--col flex--items-c">
<span
class="advert__icon advert__icon--big fas fa-bath flex flex--items-c flex--justify-c"></span>
<p class="advert__info-category">Suítes</p>
<p class="advert__info-quantity"><?php the_field('suites-quantity') ?></p>
</li>
<?php } ?>
<?php if (trim(get_field('bathroom-quantity')) != "" && trim(get_field('bathroom-quantity')) != 0) { ?>
<li class="advert__info-item flex flex--col flex--items-c">
<span
class="advert__icon advert__icon--big fas fa-shower flex flex--items-c flex--justify-c"></span>
<p class="advert__info-category">Banheiros</p>
<p class="advert__info-quantity"><?php the_field('bathroom-quantity') ?></p>
</li>
<?php } ?>
<?php if (trim(get_field('area-quantity')) != "" && trim(get_field('area-quantity')) != 0) { ?>
<li class="advert__info-item flex flex--col flex--items-c">
<span
class="advert__icon advert__icon--big fas fa-th-large flex flex--items-c flex--justify-c"></span>
<p class="advert__info-category">Área</p>
<p class="advert__info-quantity"><?php the_field('area-quantity') ?>m²</p>
</li>
<?php } ?>
<?php if (trim(get_field('parking-quantity')) != "" && trim(get_field('parking-quantity')) != 0) { ?>
<li class="advert__info-item flex flex--col flex--items-c">
<span
class="advert__icon advert__icon--big fas fa-car flex flex--items-c flex--justify-c"></span>
<p class="advert__info-category">Vagas</p>
<p class="advert__info-quantity"><?php the_field('parking-quantity') ?></p>
</li>
<?php } ?>
</ul>
<a href="<?php the_permalink(); ?>" class="advert__button btn btn--bold btn--full btn--small">
Ver mais
</a>
</div>
</div>
</div>
<?php endwhile; else: endif; ?>
</div>
<a href="/anuncios" class="adverts__cta btn btn--radius btn--full">Ver todos os anúncios</a>
</section>
<?php wp_reset_postdata(); ?>
</main>
<?php endwhile; else: endif; ?>
<?php get_footer(); ?>