homegrade_blocks_production/acf-blocks/home/questions-frequentes/questions-frequentes.php
Nonimart 3806a8897b
All checks were successful
continuous-integration/drone/push Build is passing
CHORE STYLE Updating slug and classes for thematique whos slug has changed
2025-10-27 15:50:17 +01:00

82 lines
2.5 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
$block_titling = get_field('block_titling_description_datas');
if (!function_exists('get_automatic_post')) {
function get_automatic_post($post_thematique)
{
$automatic_query_args = array(
'post_per_page' => 1,
'post_status' => 'publish',
'post_type' => 'questions',
'include_children' => true,
'tax_query' => array(
array(
'taxonomy' => 'thematiques',
'field' => 'slug',
'terms' => $post_thematique->slug,
'include_children' => true,
)
)
);
$posts = new WP_Query($automatic_query_args);
return $posts->posts[0] ?? null;
}
}
?>
<section id="block-questions-frequentes">
<div class="section_titling">
<h2 class="section_titling__title"><?php echo __("Les questions les plus fréquentes", 'homegrade-theme__texte-fonctionnel') ?></h2>
<p class="section_titling__subtitle"><?php echo __("Simplifions votre recherche !", 'homegrade-theme__texte-fonctionnel') ?></p>
</div>
<div class="questions-frequentes-grid">
<?php
$thematique_terms = get_terms(array(
'taxonomy' => 'thematiques',
'hide_empty' => false,
'parent' => 0
));
foreach ($thematique_terms as $key => $thematique) {
if (
$thematique->slug === "durabilite"
|| $thematique->slug === "duurzaamheid"
|| $thematique->slug === "au-quotidien"
|| $thematique->slug === "dagelijks"
|| $thematique->slug === "aides-financieres"
|| $thematique->slug === "financiele-steun"
|| $thematique->slug === "gezondheid-veiligheid-hygiene"
|| $thematique->slug === "sante-securite-salubrite"
) continue;
// $thematique_datas = get_term_by('slug', $thematique->slug, 'thematiques');
$manual_data = get_field($thematique->slug . '_manual_data');
$post_datas = $manual_data ? $manual_data : get_automatic_post($thematique);
get_template_part(
'template-components/cards/card-frequent-question',
null,
array(
'thematique' => $thematique,
'post_ID' => $post_datas->ID,
'post_title' => $post_datas->post_title,
'post_excerpt' => $post_datas->post_excerpt,
// 'post_url' => $post_datas->post_excerpt,
)
);
}
?>
</div>
<?php
$faq_page = get_page_by_template('template-archive-questions.php') ?? null;
$faq_page_url = $faq_page ? get_permalink($faq_page[0]->ID) : null;
?>
<?php if ($faq_page_url) : ?>
<a class="cta cta--outline cta--button" href="<?php echo $faq_page_url ?>"><?php echo __("Consulter toute la FAQ ", "homegrade-theme__texte-fonctionnel") ?></a>
<?php endif; ?>
</section>