FEATURE Affichage des termes de taxo dans l'ordre parents > enfants

This commit is contained in:
Nonimart 2025-06-13 12:52:52 +02:00
parent 1c1e7cdeae
commit ef2d6a9363

View File

@ -8,7 +8,8 @@ $post_permalink = get_the_permalink($postID);
$company_members = get_field('company_members', $postID);
$currentTaxonomy = $args['current_taxonomy'];
$taxonomyTerms = $currentTaxonomy === "elementsbatiments" ? get_the_terms($postID, 'elementsbatiments') : get_the_terms($postID, 'metiers');
// $taxonomyTerms = $currentTaxonomy === "elementsbatiments" ? get_the_terms($postID, 'elementsbatiments') : get_the_terms($postID, 'metiers');
$taxonomySortedTerms = $currentTaxonomy === "elementsbatiments" ? get_the_terms_organised_by_parent('elementsbatiments', $postID) : get_the_terms_organised_by_parent('metiers', $postID);
$phoneNumber = get_field('phone_number', $postID);
@ -38,10 +39,10 @@ $cover_image = get_field('artisan_cover', $postID);
<?php endforeach; ?>
</p>
<?php endif; ?>
<?php if ($taxonomyTerms): ?>
<div class="card-artisans__taxonomy-tags">
<?php foreach ($taxonomyTerms as $key => $term) : ?>
<span class="taxonomy-tag"><?php echo $term->name; ?></span>
<?php if ($taxonomySortedTerms): ?>
<div class="card-artisans__taxonomy-tags taxonomy-tags">
<?php foreach ($taxonomySortedTerms as $key => $term) : ?>
<span class="taxonomy-tag taxonomy-tag--<?php echo $term->parent === 0 ? 'parent' : 'child'; ?>"><?php echo $term->name; ?></span>
<?php endforeach; ?>
</div>
<?php endif; ?>