carhop__carhop-theme__DEV/template-parts/components/content-meta.php

40 lines
1.3 KiB
PHP

<?php
$current_post_id = $args['current_post_id'] ?? get_the_ID();
$current_post_type = $args['current_post_type'] ?? null;
$type = null;
$current_post_type_supports_type = get_post_type_supports_type($current_post_type);
$hasNumerotation = hasPostTypeNumerotation($current_post_type);
if ($current_post_type_supports_type) {
// $type = isset($types_terms[0]) ? $types_terms[0] : null;
$type_term = get_post_specific_type_terms($current_post_id)[0] ?? null;
if ($type_term) {
$type = $type_term->name;
}
// $current_post_type === 'analyses-etudes' && is_array($type) && !empty($type) && isset($type[0]->name
} else {
$current_post_type_obj = get_post_type_object($current_post_type);
$type = $current_post_type_obj->labels->singular_name;
}
?>
<div class="content-meta">
<?php if ($type) : ?>
<span class="content-meta__type content-meta__type--<?php echo $current_post_type ?>"><?php echo $type ?></span>
<?php endif; ?>
<?php if ($hasNumerotation) : ?>
<?php
$numerotation = get_current_post_numerotation($current_post_id);
?>
<p class="content-meta__revue-issue content-meta__revue-issue--green">
<span class="revue-issue-number revue-meta__label sr-only">Numéro</span>
<?php echo $numerotation; ?>
</p>
<?php endif; ?>
</div>