homegrade_theme_production/taxonomy-thematiques.php
2023-08-21 17:33:36 +02:00

146 lines
3.5 KiB
PHP

<?php get_header();
$thematique = get_queried_object();
$thematique_generale = get_queried_object()->parent ? get_term(get_queried_object()->parent, 'thematiques') : get_term(get_queried_object(), 'thematiques');
$thematiqueColorSlug = getThematiqueFamilySlug($thematique_generale->slug);
$current_children_thematique = get_queried_object()->parent != 0 ? get_queried_object() : null;
echo '<pre>';
print_r($thematiqueColorSlug);
echo '</pre>';
$args = array(
'posts_per_page' => 1,
'post_type' => 'conseils',
'tax_query' => array(
array(
'slug' => 'locations',
'taxonomy' => 'thematiques',
'field' => 'slug',
'terms' => get_queried_object()->slug,
// 'include_children' => false,
)
)
);
$query_current_thematique_posts = new WP_Query($args);
$thematique_related_page = $query_current_thematique_posts->posts[0];
echo '<pre>';
// print_r($term);
// print_r($term_test);
// print_r($query_current_thematique_posts->posts);
// print_r($thematique_related_page);
// print_r($current_children_thematique);
// print_r($current_thematique);
// print_r(is_tax('thematiques', 'thematiques'));
echo '</pre>';
$test = get_term_by('id', 12, 'category');
// echo '<pre>';
// print_r($thematique_related_page);
// echo '</pre>';
// echo $the_query->posts[0]->post_content;
?>
<div class="breadcrumb-thematiques">
<ul>
<li>
<a href="">Home ></a>
</li>
<li>
<a href="<?php echo get_term_link($thematique_generale) ?>"><?php echo $thematique_generale->name ?></a>
</li>
<?php if ($current_children_thematique) : ?>
<li>
<a href="<?php echo get_term_link($current_children_thematique) ?>"><?php echo $current_children_thematique->name ?></a>
</li>
<?php endif; ?>
</ul>
</div>
<div class="list_filters">
<?php if ($thematique->parent) : ?>
<?php
$sousThematiques = get_terms(array(
'child_of' => $thematique_generale->term_id,
'taxonomy' => 'thematiques',
'hide_empty' => true,
));
?>
<?php foreach ($sousThematiques as $sousThematique) : ?>
<button data-filter="<?php echo $sousThematique->slug ?>"><?php echo $sousThematique->name ?></button>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php get_template_part(
'template-components/posts-components/chapter-header',
null,
array(
'ID' => get_queried_object_id(),
'title' => __("Les questions les plus fréquentes sur ", "homegrade-theme__texte-fonctionnel__faq-archive-questions") . get_queried_object()->name,
'sub-title' => $thematique->name,
'thematique' => $thematique,
'thematique_generale' => $thematique_generale,
'thematiqueColorSlug' => $thematiqueColorSlug,
)
); ?>
<div class="post-question-page-container <?php echo $thematiqueColorSlug ? "post-question-page--" . $thematiqueColorSlug : "" ?>"">
<?php
$query_args = array(
'post_type' => 'questions',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'thematiques',
'field' => 'term_id',
'terms' => $thematique_generale->term_id,
)
)
);
$questions = new WP_Query($query_args);
?>
<?php if ($questions->have_posts()) : while ($questions->have_posts()) : $questions->the_post(); ?>
<details class=" question">
<summary>
<?php the_title(); ?>
<!-- <h2><?php the_title(); ?></h2> -->
</summary>
<div class="content">
<?php the_content(); ?>
</div>
</details>
<?php endwhile ?>
<?php endif; ?>
</div>
</div>
<?php
get_footer();