addintg mention to related conseil apge

This commit is contained in:
Antoine M 2023-11-27 16:25:53 +01:00
parent 0b27861170
commit 19073c17bf

View File

@ -101,7 +101,41 @@ $relatedTaxQuestions = new WP_Query($query_args);
<?php if ($relatedTaxQuestions->have_posts()) : while ($relatedTaxQuestions->have_posts()) : $relatedTaxQuestions->the_post(); ?> <?php if ($relatedTaxQuestions->have_posts()) : while ($relatedTaxQuestions->have_posts()) : $relatedTaxQuestions->the_post(); ?>
<?php
$questionCurrentSubthematique = get_the_terms(get_the_ID(), 'thematiques')[0] ?? null;
$relatedFichesConseilsSubThematiqueQuery = new WP_Query(array(
'post_type' => 'conseils',
'posts_per_page' => 1,
'tax_query' => array(
array(
'taxonomy' => 'thematiques',
'field' => 'term_id',
'terms' => $questionCurrentSubthematique->term_id,
)
)
));
$relatedFichesConseilsThematiqueQuery = new WP_Query(array(
'post_type' => 'conseils',
'posts_per_page' => 1,
'tax_query' => array(
array(
'taxonomy' => 'thematiques',
'field' => 'term_id',
'terms' => $mainThematique->term_id,
)
)
));
$relatedFicheConseil = $relatedFichesConseilsSubThematiqueQuery->posts[0] ?? $relatedFichesConseilsThematiqueQuery->posts[0] ?? null;
// $test = $relatedSubThematiqueQuery->posts[0] ??
echo '<pre>';
// print_r($questionCurrentSubthematique);
// print_r($relatedFichesConseilsSubThematiqueQuery->posts[0]->ID);
// print_r($relatedSubThematiqueConseil->posts[0]->ID);
echo '</pre>';
?>
<details class=" question"> <details class=" question">
<summary> <summary>
<?php the_title(); ?> <?php the_title(); ?>
@ -111,6 +145,14 @@ $relatedTaxQuestions = new WP_Query($query_args);
</summary> </summary>
<div class="content entry-content"> <div class="content entry-content">
<?php the_content(); ?> <?php the_content(); ?>
<?php if ($relatedFicheConseil) : ?>
<div class="question-context">
<p class="question-context__title"><?php echo __("Ce contenu fait parti de ", "homegrade-theme__texte-fonctionnel") ?></p>
<a class="question-context__conseil-name" href="<?php echo get_permalink($relatedFicheConseil) ?>">
<?php echo $relatedFicheConseil->post_title ?>
</a>
</div>
<?php endif; ?>
</div> </div>
</details> </details>