From 6cd96ec9caf22a15799a04ac123c370fc1e885db Mon Sep 17 00:00:00 2001 From: Antoine M Date: Wed, 22 Nov 2023 13:51:48 +0100 Subject: [PATCH] changing get posts to wp_query to avoid mixing languages --- template-blocks/home/latest-news/latest-news.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/template-blocks/home/latest-news/latest-news.php b/template-blocks/home/latest-news/latest-news.php index 693c86e..728d783 100644 --- a/template-blocks/home/latest-news/latest-news.php +++ b/template-blocks/home/latest-news/latest-news.php @@ -11,23 +11,27 @@ $block_titling_datas = get_field('block_titling_datas');
'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); - foreach ($recent_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']); + + 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_ID' => $post->ID, + 'post_title' => $post->post_title, 'post_thumbnail' => $post_thumbnail, 'post_tags' => $post_tags, )