FIX Querying field articles instead of wpwuery to get post in the right order
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Antoine M 2025-06-19 13:13:39 +02:00
parent dac2aa73e7
commit ad3d784762
2 changed files with 20 additions and 60 deletions

View File

@ -17,31 +17,7 @@ $last_issue = $dynamiques->posts[0];
if (!$last_issue) return;
$issueNumber = get_field('issue_number', $last_issue->ID);
$issue_related_articles = new WP_Query(array(
'post_type' => 'articles',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'related_revue',
'value' => $last_issue->ID,
'compare' => '=',
),
),
));
// if ($currentPostType === 'revues') {
// $currentRevueID = get_the_ID();
// }
// if ($currentPostType === 'articles') {
// $currentRevueID = get_field('related_revue', get_the_ID());
// }
// if (!$currentRevueID) return;
$issue_related_articles = get_field('articles', $last_issue->ID);
?>
<section class="block-dernieres-dynamiques content-section ">
@ -143,18 +119,20 @@ $issue_related_articles = new WP_Query(array(
<?php endforeach; ?>
<?php else : ?>
<div class="article-caroussel__slider">
<?php if ($issue_related_articles->have_posts()) : ?>
<?php if ($issue_related_articles && is_array($issue_related_articles)) : ?>
<div class="swiper dernieres-dynamiques-swiper">
<div class="swiper-wrapper">
<?php while ($issue_related_articles->have_posts()) : $issue_related_articles->the_post(); ?>
<?php foreach (
$issue_related_articles as $article
) : ?>
<article class="article-card swiper-slide">
<div class="content-meta">
<span class="content-meta__type content-meta__type--article">Article</span>
</div>
<div class="article-card__content">
<h4 class="article-card__title title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<h4 class="article-card__title title"><a href="<?php echo get_the_permalink($article->ID); ?>"><?php echo get_the_title($article->ID); ?></a></h4>
<?php
$etiquettes = get_the_terms(get_the_ID(), 'etiquettes');
$etiquettes = get_the_terms($article->ID, 'etiquettes');
if ($etiquettes): ?>
<ul class="article-tags-list">
@ -183,7 +161,9 @@ $issue_related_articles = new WP_Query(array(
</article>
<?php endwhile; ?>
<?php endforeach; ?>
</div>
<div class="swiper-pagination-fraction"></div>

View File

@ -17,31 +17,7 @@ $last_issue = $dynamiques->posts[0];
if (!$last_issue) return;
$issueNumber = get_field('issue_number', $last_issue->ID);
$issue_related_articles = new WP_Query(array(
'post_type' => 'articles',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'related_revue',
'value' => $last_issue->ID,
'compare' => '=',
),
),
));
// if ($currentPostType === 'revues') {
// $currentRevueID = get_the_ID();
// }
// if ($currentPostType === 'articles') {
// $currentRevueID = get_field('related_revue', get_the_ID());
// }
// if (!$currentRevueID) return;
$issue_related_articles = get_field('articles', $last_issue->ID);
?>
<section class="block-dernieres-dynamiques content-section ">
@ -143,18 +119,20 @@ $issue_related_articles = new WP_Query(array(
<?php endforeach; ?>
<?php else : ?>
<div class="article-caroussel__slider">
<?php if ($issue_related_articles->have_posts()) : ?>
<?php if ($issue_related_articles && is_array($issue_related_articles)) : ?>
<div class="swiper dernieres-dynamiques-swiper">
<div class="swiper-wrapper">
<?php while ($issue_related_articles->have_posts()) : $issue_related_articles->the_post(); ?>
<?php foreach (
$issue_related_articles as $article
) : ?>
<article class="article-card swiper-slide">
<div class="content-meta">
<span class="content-meta__type content-meta__type--article">Article</span>
</div>
<div class="article-card__content">
<h4 class="article-card__title title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<h4 class="article-card__title title"><a href="<?php echo get_the_permalink($article->ID); ?>"><?php echo get_the_title($article->ID); ?></a></h4>
<?php
$etiquettes = get_the_terms(get_the_ID(), 'etiquettes');
$etiquettes = get_the_terms($article->ID, 'etiquettes');
if ($etiquettes): ?>
<ul class="article-tags-list">
@ -183,7 +161,9 @@ $issue_related_articles = new WP_Query(array(
</article>
<?php endwhile; ?>
<?php endforeach; ?>
</div>
<div class="swiper-pagination-fraction"></div>