-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage-adverts.php
More file actions
213 lines (192 loc) · 9.96 KB
/
page-adverts.php
File metadata and controls
213 lines (192 loc) · 9.96 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
<?php
// Template Name: Anúncios
?>
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<main class="page-content page-content--adverts">
<div class="innerTitle container">
<p class="innerTitle__text">O imóvel certo pra você</p>
<h2 class="innerTitle__title">Nossos anúncios</h2>
</div>
<?php
$args = array(
'post_type' => 'imoveis',
'order' => 'DESC',
'posts_per_page' => -1,
);
$the_query = new WP_Query ($args);
?>
<section class="advert container">
<div class="flex row gutter flex--items-start">
<div class="advert__filters col-2">
<div class="flex flex--justify-c flex--col filter-button-group">
<button class="flex flex--items-c active" data-filter="*">Todos</button>
</div>
<div class="flex flex--justify-c flex--col filter-button-group">
<?php
$terms = get_terms('categoria_imoveis');
foreach ($terms as $term) { ?>
<button class="flex flex--items-c"
data-url="categoria=<?php echo $term->slug; ?>"
data-filter=".<?php echo $term->slug; ?>">
<?php echo $term->name; ?>
</button>
<?php
}
?>
</div>
<div class="flex flex--justify-c flex--col filter-button-group">
<?php
$terms2 = get_terms('condicao_imoveis');
foreach ($terms2 as $term) { ?>
<button class="flex flex--items-c"
data-url="condicao=<?php echo $term->slug; ?>"
data-filter=".<?php echo $term->slug; ?>">
<?php echo $term->name; ?>
</button>
<?php
}
?>
</div>
<div class="flex flex--justify-c flex--col filter-button-group">
<?php
$terms3 = get_terms('tipo_imoveis');
foreach ($terms3 as $term) { ?>
<button class="flex flex--items-c"
data-url="tipo=<?php echo $term->slug; ?>"
data-filter=".<?php echo $term->slug; ?>">
<?php echo $term->name; ?>
</button>
<?php
}
?>
</div>
</div>
<div class="grid advert__list flex row gutter flex--justify-c flex--wrap content col-10">
<?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="grid-item col-5 <?php echo $termsSlugCategory; ?> <?php echo $termsSlugCondition ?> <?php echo $termsSlugType ?>">
<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; ?>
<?php wp_reset_query();
wp_reset_postdata(); ?>
</div>
</div>
</section>
<div class="cta flex flex--items-c flex--justify-c">
<img
src="<?php the_field('foto-cta'); ?>"
alt="<?php the_field('foto-cta-alt'); ?>" class="cta__background">
<div class="cta__content">
<p class="cta__text">Anúncie seu imóvel conosco</p>
<a href="/contato" class="cta__button btn btn--radius flex flex--items-c flex--justify-c">Entre em
contato</a>
</div>
</div>
</main>
<?php endwhile; else: endif; ?>
<?php get_footer(); ?>