31 lines
822 B
PHP
31 lines
822 B
PHP
<?php
|
|
$post_amount = $args['post_amount'] ?? 1;
|
|
$post_type = $args['post_type'] ?? null;
|
|
if (!$post_type) return;
|
|
|
|
$posts_query = new WP_Query(array(
|
|
'post_type' => $post_type,
|
|
'posts_per_page' => $post_amount,
|
|
'orderby' => 'date',
|
|
'order' => 'DESC',
|
|
|
|
));
|
|
$posts = $posts_query->posts;
|
|
$current_post_type = $args['current_post_type'] ?? get_post_type();
|
|
|
|
?>
|
|
|
|
|
|
<div class="latest-parutions">
|
|
<?php if ($post_amount > 1) : ?>
|
|
<h2 class="latest-parutions__title title-small">Dernières parutions</h2>
|
|
<?php else : ?>
|
|
<h2 class="latest-parutions__title title-small">Dernière parution</h2>
|
|
<?php endif; ?>
|
|
|
|
<?php foreach ($posts as $post) : ?>
|
|
<?php get_template_part('template-parts/components/post-card', null, array(
|
|
'ID' => get_the_ID(),
|
|
)); ?>
|
|
<?php endforeach; ?>
|
|
</div>
|