-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory.php
72 lines (54 loc) · 1.76 KB
/
category.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
<?php
/**
* The main template file
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Studio Val
*/
get_header();
// === Graphic blocks definition
$blocks = [
studio_define_graphic_block('primary', 'small'),
studio_define_graphic_block('primary', 'large'),
studio_define_graphic_block('dark', 'medium'),
];
// === Get the current category
$category = get_queried_object();
// === Latests posts from a given category
$posts_args = array(
'post_type' => 'post',
'posts_per_page' => 6,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => $category->term_id,
)),
);
$posts_query = new WP_Query($posts_args);
// === Icons
$icon_arrow = file_get_contents(get_template_directory_uri() . '/assets/svg/arrow-rounded.svg');
?>
<main id="content" class="st-blog category">
<section class="st-section boxed st-blog__header">
<?php get_template_part('template-parts/breadcrumbs'); ?>
<h1><?php _e("Articles de la catégorie \"<strong>$category->name</strong>\"", "studio-val"); ?></h1>
<p><?php echo $category->description; ?></p>
<?php echo studio_generate_graphic_blocks($blocks); ?>
</section>
<section class="st-section boxed st-blog__posts">
<div class="st-blog__posts-list">
<?php if ($posts_query->have_posts()) : ?>
<?php while ($posts_query->have_posts()) : $posts_query->the_post(); ?>
<?php get_template_part('template-parts/card', 'post'); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
</div>
</section>
</main>
<?php
get_footer();