From d6d20c5ae22dcf2701d678e804d1164705fb074a Mon Sep 17 00:00:00 2001 From: Antoine M Date: Thu, 30 Nov 2023 17:50:31 +0100 Subject: [PATCH] switching from get_recent posts to wp query --- .../home/latest-news/latest-news.php | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/template-blocks/home/latest-news/latest-news.php b/template-blocks/home/latest-news/latest-news.php index 728d783..fe89e6b 100644 --- a/template-blocks/home/latest-news/latest-news.php +++ b/template-blocks/home/latest-news/latest-news.php @@ -11,34 +11,52 @@ $block_titling_datas = get_field('block_titling_datas');
4, 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'DESC', - 'numberposts' => 4, // Number of recent posts thumbnails to display 'post_status' => 'publish' // Show only the published posts - )); - $recent_posts = new WP_Query($args); + ); + $recentNewsPosts = new WP_Query($args); + // echo '
';
+		// print_r($recentNewsPosts);
+		// echo '
'; - foreach ($recent_posts->posts as $key => $post) { - $post_thumbnail = get_the_post_thumbnail($post->ID, 'full', array('class' => 'card-news__thumbnail')); - $post_tags = get_the_tags($post->ID); - - get_template_part( - 'template-components/cards/card-news', - null, - array( - 'card_variant' => 'activite', - 'post_ID' => $post->ID, - 'post_title' => $post->post_title, - 'post_thumbnail' => $post_thumbnail, - 'post_tags' => $post_tags, - ) - ); - } ?> + have_posts()) : while ($recentNewsPosts->have_posts()) : $recentNewsPosts->the_post(); ?> + ID, 'full', array('class' => 'card-news__thumbnail')); + $news_type = get_the_terms($post->ID, "news_type") ?? null; + + get_template_part( + 'template-components/cards/card-news', + null, + array( + 'card_variant' => 'activite', + 'post_ID' => $post->ID, + 'post_title' => get_the_title(), + 'post_thumbnail' => $post_thumbnail, + 'news_type' => $news_type, + 'post_date' => $post_date, + ) + ); + ?> + +
+ '_wp_page_template', + 'meta_value' => "template-archive-news.php" + ); + $relatedPageTemplatePage = get_pages($args) ? get_pages($args)[0] : null; + ?> + + + + \ No newline at end of file