carhop__carhop-theme__DEV/template-parts/components/archive/post-grid.php

32 lines
1.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();
$posts_query = new WP_Query(array(
'post_type' => $current_post_type,
'posts_per_page' => $post_amount
));
?>
<section class="post-grid content-section">
<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,
)); ?>
<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>