homegrade_theme_production/template-blocks/home/latest-news/latest-news.php

40 lines
1.1 KiB
PHP

<?php
$block_titling_datas = get_field('block_titling_datas');
?>
<section class="section_latest_news">
<div class="section_titling">
<h2 class="section_titling__title"><?php echo $block_titling_datas['title'] ?></h2>
<h3 class="section_titling__subtitle"><?php echo $block_titling_datas['subtitle'] ?></h3>
</div>
<div class="articles_container">
<?php
$recent_posts = wp_get_recent_posts(array(
'post_type' => 'post',
'numberposts' => 4, // Number of recent posts thumbnails to display
'post_status' => 'publish' // Show only the published posts
));
foreach ($recent_posts as $key => $post) {
$post_thumbnail = get_the_post_thumbnail($post['ID'], 'full', array('class' => 'post-card__thumbnail'));
$post_tags = get_the_tags($post['ID']);
get_template_part(
'template-components/post-card',
null,
array(
'card_variant' => 'activite',
'post_ID' => $post['ID'],
'post_title' => $post['post_title'],
'post_thumbnail' => $post_thumbnail,
'post_tags' => $post_tags,
)
);
}
?>
</div>
</section>