93 lines
3.0 KiB
PHP
93 lines
3.0 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();
|
|
$current_post_type_obj = get_post_type_object($current_post_type);
|
|
|
|
$posts_query = new WP_Query(array(
|
|
'post_type' => $current_post_type,
|
|
'posts_per_page' => $post_amount
|
|
));
|
|
$post_count = $posts_query->post_count;
|
|
|
|
$types = get_terms(array(
|
|
'taxonomy' => 'type',
|
|
'hide_empty' => true,
|
|
));
|
|
|
|
// write_log($current_post_type_obj);
|
|
|
|
?>
|
|
|
|
<section class="post-grid content-section">
|
|
<h2 class="find-publication__title title-small"><?php echo $grid_title; ?></h2>
|
|
<div class="content-section__inner">
|
|
|
|
<div class="post-grid__toolbar">
|
|
|
|
<div class="search-by">
|
|
<p class="search-by__label">Filtrer par</p>
|
|
<div class="search-by__buttons" data-filter="thematique">
|
|
<button data-filter="thematique" aria-selected="true">Thématique</button>
|
|
<button data-filter="occurence" aria-selected="false">Mot clé</button>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="post-grid__toolbar-actions" data-post-type="revues">
|
|
<div class="search-bar">
|
|
<input type="text" placeholder="<?php _e('Rechercher par mot-clé', 'dynamiques'); ?>">
|
|
</div>
|
|
|
|
<select name="types">
|
|
<option value=""><?php _e('Tous les types', 'carhop'); ?></option>
|
|
<?php foreach ($types as $type) : ?>
|
|
<option value="<?php echo $type->slug; ?>" <?php selected($type_slug, $type->slug); ?>>
|
|
<?php echo $type->name; ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<select name="auteurs">
|
|
<option value=""><?php _e('Tous·tes les auteur·e·s', 'dynamiques'); ?></option>
|
|
<?php foreach ($authors as $author) : ?>
|
|
<option value="<?php echo $author->ID; ?>"><?php echo $author->post_title; ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
|
|
|
|
</div>
|
|
|
|
<h2 class="post-count">
|
|
<span class="post-count__count">
|
|
<?php echo $post_count; ?>
|
|
</span>
|
|
<?php if ($post_amount > 1) : ?>
|
|
<span class="post-count__text">
|
|
<?php echo $current_post_type_obj->labels->name; ?>
|
|
</span>
|
|
<?php else : ?>
|
|
<span class="post-count__text">
|
|
<?php echo $current_post_type_obj->labels->singular_name; ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</h2>
|
|
<select name="sort_by">
|
|
<option value="date_desc" selected><?php _e('Numéros récents en premier', 'dynamiques'); ?></option>
|
|
<option value="date_asc"><?php _e('Numéros anciens en premier', 'dynamiques'); ?></option>
|
|
<option value="title_asc"><?php _e('Par ordre alphabétique', 'dynamiques'); ?></option>
|
|
</select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<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/post-card', null, array(
|
|
'ID' => get_the_ID(),
|
|
)); ?>
|
|
<?php endwhile; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</section>
|