FEATURE introducing component
This commit is contained in:
parent
6bbaaefe85
commit
2633d743a8
52
template-parts/post-types/actualites/archive-grid.php
Normal file
52
template-parts/post-types/actualites/archive-grid.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
$post_amount = $args['post_amount'] ?? -1;
|
||||
$current_post_type = $args['current_post_type'] ?? get_post_type();
|
||||
|
||||
// Récupérer le paramètre etiquette de l'URL
|
||||
$etiquette_slug = isset($_GET['etiquette']) ? sanitize_text_field($_GET['etiquette']) : '';
|
||||
|
||||
|
||||
// Construire les arguments de la query
|
||||
$query_args = array(
|
||||
'post_type' => $current_post_type,
|
||||
'posts_per_page' => $post_amount,
|
||||
'post_status' => 'publish',
|
||||
);
|
||||
|
||||
// Si on a une étiquette, ajouter le filtre taxonomy
|
||||
if (!empty($etiquette_slug)) {
|
||||
$query_args['tax_query'] = array(
|
||||
array(
|
||||
'taxonomy' => 'etiquettes',
|
||||
'field' => 'slug',
|
||||
'terms' => $etiquette_slug,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$posts_query = new WP_Query($query_args);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<section class="post-grid content-section <?php echo !empty($etiquette_slug) ? 'has-initial-filter' : '' ?>">
|
||||
<div class="content-section__inner">
|
||||
|
||||
<?php get_template_part('template-parts/post-types/actualites/archive-grid-toolbar', null, array(
|
||||
'posts_query' => $posts_query,
|
||||
'current_post_type' => $current_post_type,
|
||||
'etiquette_active_filter_slug' => $etiquette_slug,
|
||||
)); ?>
|
||||
|
||||
<ul class="post-grid__list">
|
||||
<?php if (isset($posts_query) && $posts_query->have_posts()) : ?>
|
||||
<?php while ($posts_query->have_posts()) : $posts_query->the_post(); ?>
|
||||
<?php get_template_part('template-parts/components/cards/post-card', null, array(
|
||||
'ID' => get_the_ID(),
|
||||
)); ?>
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
Loading…
Reference in New Issue
Block a user