54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
$post_amount = $args['post_amount'] ?? -1;
|
|
$grid_title = $args['grid_title'] ?? 'Trouver une publication';
|
|
$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' : '' ?>">
|
|
<h2 class="find-publication__title title-small"><?php echo $grid_title; ?></h2>
|
|
<div class="content-section__inner">
|
|
|
|
<?php get_template_part('template-parts/components/archive/post-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>
|