homegrade_theme_production/single-questions.php
2023-11-27 13:05:58 +01:00

97 lines
3.0 KiB
PHP

<?php
get_header();
?>
<?php if (have_posts()) : ?>
<?php
while (have_posts()) :
the_post();
$currentThematique = get_the_terms(get_the_ID(), 'thematiques')[0];
$mainThematique = getMainThematique($currentThematique);
$thematiqueColorSlug = $mainThematique->slug;
$args = array(
'post_type' => 'conseils',
'tax_query' => array(
array(
'taxonomy' => 'thematiques',
'field' => 'slug',
'terms' => $mainThematique->slug,
)
)
);
$relatedConseils = new WP_Query($args);
$relatedConseilsUrl = get_permalink($relatedConseils->posts[0]->ID) ?? null;
?>
<div class="post-question-page-container <?php echo $thematiqueColorSlug ? "post-question-page--" . $thematiqueColorSlug : "" ?>">
<?php get_template_part('template-components/post-questions/chapter-header', null, array(
'postID' => get_the_ID(),
)); ?>
<article class="container my-8 mx-auto entry-content single-editor-content <?php echo $thematiqueColorSlug ? "entry-content--" . $thematiqueColorSlug : "" ?>">
<?php the_content() ?>
</article>
<?php
?>
<?php get_template_part('template-components/post-conseils/chapter-header', null, array(
'postID' => get_the_ID(),
'title' => __("Retrouvez nos conseils sur l'isolation dans notre brochure écrite par des experts", "homegrade-theme__texte-fonctionnel"),
'hasInfoCapsule' => false,
'ctaUrl' => $relatedConseilsUrl,
'ctaTitle' => __("Consulter nos conseils sur ", "homegrade-theme__texte-fonctionnel") . $mainThematique->name,
'ctaTarget' => "_self",
)); ?>
<!-- PUBLCIATIONS SUGGÉRÉS -->
<div class="card-large-content-container">
<?php
$args = array(
'post_type' => 'brochures',
'posts_per_page' => 5,
'orderby' => 'rand',
'post_status' => 'publish',
);
$suggestedPublications = new WP_Query($args);
$pagePublicationsUrl = get_page_by_template('template-publications.php') ? get_permalink(get_page_by_template('template-publications.php')[0]->ID) : null;
?>
<div class="card-large-content">
<div class="section_titling">
<h2 class="section_titling__title"><?php echo __("Publications suggérées", "homegrade-theme__texte-fonctionnel") ?></h2>
<p class="section_titling__subtitle"><?php echo __("Consultez notre documentation pour en savoir plus", "homegrade-theme__texte-fonctionnel") ?></p>
</div>
<ul id="brochures-rows" class="publications-grid">
<?php
get_template_part(
'template-components/archives/brochure-rows',
null,
array(
'brochuresPosts' => $suggestedPublications,
)
)
?>
</ul>
<a class="cta cta--outline cta--button mx-auto" href="<?php echo $pagePublicationsUrl ?>"><?php echo __("Consulter toutes les publications", "homegrade-theme__texte-fonctionel") ?></a>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php
get_footer();