-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcategory.php
More file actions
357 lines (323 loc) · 18.5 KB
/
category.php
File metadata and controls
357 lines (323 loc) · 18.5 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
<?php get_header(); ?>
<!------------------
| Banner
|------------------>
<?php
#ALTERE AQUI O TITULO E O NOME DA IMAGEM DO BANNER
$img = get_template_directory_uri().'/assets/img/blog-img.png';
includeFile('components/banner.php',
array(
'title'=>'BLOG',
'imagem'=> $img,
'subtitle' => 'Acompanhe as novidades da UpValue'
)
);
?>
<!------------------
| Destaques
|------------------>
<main class="position-relative">
<img class="position-absolute d-none d-xl-block" id="pattern-roxo" src="<?php echo get_template_directory_uri(); ?>/assets/icons/pattern-roxo.svg"/>
<img class="position-absolute d-none d-xl-block" id="pattern-azul" src="<?php echo get_template_directory_uri(); ?>/assets/icons/pattern-azul.svg"/>
<div class="container py-5">
<section class="mb-5 pb-4" id="highlight">
<div class="col-12 mb-5 pb-3" id="highlight-header">
<div class="mb-4">
<div class="d-flex align-items-center">
<h4 class="me-3">DESTAQUES</h4>
<hr class="w-25">
</div>
</div>
<h3 id="title">Últimas atualizações</h3>
</div>
<!------------------
| ultimos posts
|------------------>
<div class="row d-lg-flex justify-content-lg-between" id="highlight-content">
<!------------------
| Post único
|------------------>
<?php
$sticky = get_option('sticky_posts');
if (!empty($sticky)) {
$args = array(
'post_type' => 'post',
'posts_per_page' => 1,
'post__in' => $sticky
);
}
else{
$args = array(
'post_type' => 'post',
'posts_per_page' => 1
);
}
$relate_query = new WP_Query($args);
if($relate_query->have_posts()) : while ($relate_query->have_posts()) : $relate_query->the_post();
?>
<div class="col-12 col-lg-8">
<a href="<?php echo get_permalink();?>">
<!------------------
| Featured Image
|------------------>
<div class="d-flex flex-wrap" id="highlight-post">
<div class="col-12 post-frame">
<img class="thumb h-100 w-100 rounded-3" <?php if(!has_post_thumbnail( $post->ID )){
echo "no-thumbnail";
}?>"
src="<?php if(has_post_thumbnail( $post->ID )){
echo get_the_post_thumbnail_url($post->ID);
}
else{
//alterar a imagem para um placeholder feito
echo get_template_directory_uri()."/assets/img/banner.jpg";
}?>
"
alt="<?php the_title();?>"
>
<div class="bt-h">
<button>Ver postagem</button>
</div>
</div>
<div class="d-flex flex-column justify-content-between col-12 mt-3" id="post-info">
<div class="d-flex flex-wrap justify-content-between mb-4">
<div class="d-flex" id="author">
<img class="me-2" src="<?php echo get_template_directory_uri(); ?>/assets/icons/author.svg" alt="Author icone">
<p class="body-2"><?php the_author();?></p>
</div>
<div class="d-flex justify-content-between ">
<?php the_date( 'd-m-Y', '<p class="body-2">', '</p>' ); ?>
<p class="body-2 mx-2">/</p>
<p class="body-2">
<?php $content = get_post_field( 'post_content', $post->ID );
$quantidade_palavras = str_word_count( strip_tags( $content ) );
$tempo_leitura = ceil($quantidade_palavras / 250);
if($tempo_leitura == 1){
echo $tempo_leitura." min de leitura";
}
else{
echo strval($tempo_leitura)." min de leitura";
}
?>
</p>
</div>
</div>
<!------------------
| Titulo
|------------------>
<h3 class="first-title">
<?php
if (strlen($post->post_title) > 75) {
echo substr(the_title($before = '', $after = '', FALSE), 0, 75) . '...'; }
else {
the_title();
}
?>
</h3>
</div>
</div>
</a>
</div>
<?php endwhile; else: endif; wp_reset_postdata();?>
<!------------------
| Trio de posts
|------------------>
<div class="col-12 col-lg-4">
<?php
$sticky = get_option('sticky_posts');
$count = 1;
if (!empty($sticky)) {
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'post__not_in' => $sticky
);
}
else{
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'offset' => 1
);
}
$relate_query = new WP_Query($args);
if($relate_query->have_posts()) : while ($relate_query->have_posts()) : $relate_query->the_post();
?>
<div class="col-12 ">
<a href="<?php echo get_permalink();?>">
<?php
/*------------------
| Titulo
|------------------*/
$titulo = '';
if (strlen($post->post_title) > 36) {
$titulo = substr(the_title($before = '', $after = '', FALSE), 0, 36) . '...'; }
else {
$titulo= esc_html( get_the_title() );
}
if($count == 2){
echo '<hr class="w-100 mt-4 mb-4" style="border: 0; height: 2px;
background-color: var(--neutral);">';
}
/*------------------
| Tempo de leitura
|------------------*/
$tempo = '';
$content = get_post_field( 'post_content', $post->ID );
$quantidade_palavras = str_word_count( strip_tags( $content ) );
$tempo_leitura = ceil($quantidade_palavras / 250);
if($tempo_leitura == 1){
$tempo = $tempo_leitura." min de leitura";
}
else{
$tempo = strval($tempo_leitura)." min de leitura";
}
includeFile('components/card-blog.php', array(
'imgUrl' => $post->ID,
'title' => $titulo,
'author' => esc_html( get_the_author() ),
'date' => get_the_date('d-m-Y'),
'readingTime' => $tempo,
'color' => '',
'class' => '',
));
if($count == 2){
echo '<hr class="w-100 mt-4 mb-4" style="border: 0; height: 2px;
background-color: var(--neutral); ">';
}
$count+=1;
?>
</a>
</div>
<?php endwhile; else: endif; wp_reset_postdata();?>
</div>
</div>
</section>
<hr class="w-100 neutral d-none d-lg-block">
<section class="mt-5" id="most-recent">
<div class="col-12 d-flex flex-wrap justify-content-between" id="posts-header">
<div>
<?php
$category = get_category( get_query_var( 'cat' ) );
$cat_id = $category->cat_name;
?>
<h3 class="mb-4" id="title">Postagens - <?php echo $cat_id;?></h3>
</div>
<div class="dropdown mb-4">
<button class="btn dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
Filtrar por categoria
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
<?php
$argsCat = array (
'orderby' => 'name',
'order' => 'ASC'
);
$categories = get_categories($argsCat);
foreach( $categories as $category ) {
echo '
<li>
<a class="dropdown-item" href="' . get_category_link($category->term_id) . '">
' . $category->name . '
</a>
</li>
';
}
?>
</ul>
</div>
</div>
<div class="row">
<?php
$query = new WP_Query($wp_query->query_vars);
if($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
?>
<div class="col-12 col-sm-6 col-lg-4 mb-5">
<a href="<?php echo get_permalink();?>">
<div class="d-flex flex-wrap" id="most-recent-post">
<div class="col-12 post-frame">
<img class="thumb h-100 w-100 rounded-3" <?php if(!has_post_thumbnail( $post->ID )){
echo "no-thumbnail";
}?>"
src="<?php if(has_post_thumbnail( $post->ID )){
echo get_the_post_thumbnail_url($post->ID);
}
else{
//alterar a imagem para um placeholder feito
echo get_template_directory_uri()."/assets/img/banner.jpg";
}?>
"
alt="<?php the_title();?>"
>
<div class="bt-h">
<button>Ver postagem</button>
</div>
</div>
<div class="d-flex flex-column justify-content-between col-12 mt-3" id="post-info">
<div class="d-flex flex-wrap justify-content-between mb-2">
<p class="body-2">
<img class="" src="<?php echo get_template_directory_uri(); ?>/assets/icons/calendar.svg" alt="Calendario icone">
<?php setlocale(LC_TIME, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
date_default_timezone_set('America/Sao_Paulo');
echo strftime('%d/%m/%Y', strtotime($post->post_date));?>
</p>
<p class="body-2">
<img class="" src="<?php echo get_template_directory_uri(); ?>/assets/icons/clock.svg" alt="Relogio icone">
<?php $content = get_post_field( 'post_content', $post->ID );
$quantidade_palavras = str_word_count( strip_tags( $content ) );
$tempo_leitura = ceil($quantidade_palavras / 250);
if($tempo_leitura == 1){
echo $tempo_leitura."min de leitura";
}
else{
echo strval($tempo_leitura)."min de leitura";
}
?>
</p>
</div>
<h4 class="first-title">
<?php
if (strlen($post->post_title) > 56) {
echo substr(the_title($before = '', $after = '', FALSE), 0, 56) . '...'; }
else {
the_title();
}
?>
</h4>
</div>
</div>
</a>
</div>
<?php endwhile; else: endif; wp_reset_postdata();?>
<div class="posts-pagination mt-3 mb-5 d-flex flex-wrap justify-content-center">
<?php $prev_next = paginate_links(array(
'prev_text' => __( '<' ),
'next_text' => __( '>' ),
'type' => 'array',
'end_size' => '2',
));
if($prev_next){
foreach($prev_next as $key=>$val){
if (strpos($val,'"page-numbers current"') !== false) {
echo '<div class="active page-item px-2">'.$val.'</div>';
} elseif (strpos($val,'"next page-numbers"') !== false || strpos($val,'"prev page-numbers"') !== false ) {
echo'<div class="prevnext px-2">'.$val.'</div>';
} else {
echo '<div class="page-item px-2">'.$val.'</div>';
}
} }?>
</div>
</div>
</section>
</div>
<section id="contact-cta">
<div class="container">
<div class="d-flex flex-column align-items-center">
<h3 class="mb-5 f-neutral text-center px-5">Temos soluções que irão ajudar o seu negócio a alcançar resultados exponenciais!</h3>
<a href="<?php echo get_home_url()?>/#contact"><button class="neutral">Entrar em contato</button></a>
</div>
</div>
</section>
</main>
<?php get_footer(); ?>