FEATURE Introducing the toolbar component
This commit is contained in:
parent
162e0d06e0
commit
239f2be885
74
template-parts/components/archive/post-grid-toolbar.php
Normal file
74
template-parts/components/archive/post-grid-toolbar.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
$current_post_type = $args['current_post_type'] ?? get_post_type();
|
||||
$posts_query = $args['posts_query'] ?? null;
|
||||
$post_count = $posts_query->post_count;
|
||||
$current_post_type_obj = get_post_type_object($current_post_type);
|
||||
|
||||
|
||||
$post_ids = wp_list_pluck($posts_query->posts, 'ID');
|
||||
|
||||
$types = get_terms(array(
|
||||
'taxonomy' => 'type',
|
||||
'hide_empty' => true,
|
||||
));
|
||||
|
||||
$authors = get_authors_linked_to_posts($post_ids);
|
||||
$tags = get_terms(array(
|
||||
'taxonomy' => 'etiquettes',
|
||||
'hide_empty' => true,
|
||||
'object_ids' => $post_ids,
|
||||
));
|
||||
|
||||
?>
|
||||
|
||||
<div class="post-grid__toolbar">
|
||||
<div class="search-by">
|
||||
<p class="search-by__label">Filtrer par</p>
|
||||
<div class="search-by__buttons">
|
||||
<button data-filter="thematique" aria-selected="true">Thématique</button>
|
||||
<button data-filter="auteur" aria-selected="false">Auteur</button>
|
||||
<button data-filter="occurence" aria-selected="false">Mot clé</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="post-grid__toolbar-actions" data-post-type="<?php echo $current_post_type; ?>">
|
||||
<div class="search-bar">
|
||||
<input type="text" placeholder="<?php _e('Rechercher par mot-clé', 'dynamiques'); ?>">
|
||||
</div>
|
||||
|
||||
|
||||
<select name="etiquettes">
|
||||
<option value=""><?php _e('Tous les tags', 'dynamiques'); ?></option>
|
||||
<?php foreach ($tags as $tag) : ?>
|
||||
<option value="<?php echo $tag->slug; ?>"><?php echo $tag->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>
|
||||
Loading…
Reference in New Issue
Block a user