carhop__plugins__PROD-DEV/plugins/carhop-blocks/build/dbmob-archives/render.php

62 lines
1.9 KiB
PHP

<?php
$initialPostDisplayAmount = 10;
$args = array(
'post_type' => 'dbmob',
'posts_per_page' => $initialPostDisplayAmount,
);
$query = new WP_Query($args);
$post_count = $query->found_posts;
?>
<section <?php echo get_block_wrapper_attributes(); ?>>
<h2>Les notices rédigées par le CARHOP</h2>
<div class="notices-toolbar" data-post-type="dbmob">
<h2 class="post-count">
<span class="post-count__count">
<?php echo $post_count; ?>
</span>
<span class="post-count__text">
<?php _e('notices biographiques', 'carhop-blocks'); ?>
</span>
</h2>
<select class="sort_by" name="sort_by" id="sort_by">
<option value="date_desc" selected><?php _e('Voir les dernières notices en premier', 'carhop-blocks'); ?></option>
<option value="date_asc"><?php _e('Voir les plus anciennes notices en premier', 'carhop-blocks'); ?></option>
</select>
<div class="search-bar">
<label for="search-input"><?php _e('Rechercher une notice par nom', 'carhop-blocks'); ?></label>
<input type="text" placeholder="<?php _e('Rechercher par nom', 'carhop-blocks'); ?>" name="search">
</div>
</div>
<?php if ($query->have_posts()) : ?>
<div class="dbmob-grid">
<?php while ($query->have_posts()) : $query->the_post(); ?>
<?php $maitron_url = get_field('maitron_url', get_the_ID()); ?>
<?php get_template_part('template-parts/components/cards/post-card', null, array(
'ID' => get_the_ID(),
'current_post_type' => 'dbmob',
'has_external_link' => isset($maitron_url) && !empty($maitron_url),
'external_link' => $maitron_url,
'external_link_text' => 'Voir la notice',
)); ?>
<?php endwhile; ?>
</ul>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</div>
<?php if ($post_count > $initialPostDisplayAmount) : ?>
<button class="load-more-button" data-offset="0" data-posts-per-page="-1">Afficher plus</button>
<?php endif; ?>
</section>