handling null value

This commit is contained in:
Antoine M 2023-11-28 16:25:28 +01:00
parent 7e075648a5
commit ee5abab657

View File

@ -5,13 +5,11 @@ $fichesInfosPosts = $args['fichesInfosPosts'];
<?php if ($fichesInfosPosts->have_posts()) : while ($fichesInfosPosts->have_posts()) : $fichesInfosPosts->the_post(); ?> <?php if ($fichesInfosPosts->have_posts()) : while ($fichesInfosPosts->have_posts()) : $fichesInfosPosts->the_post(); ?>
<?php <?php
$ficheInfoPdf = get_field('brochure_pdf', get_the_ID()); $ficheInfoPdf = get_field('brochure_pdf', get_the_ID()) ?? null;;
// $ficheInfoCover = get_field('brochure_cover', get_the_ID());
// $ficheInfoCover = get_field('brochure_cover_image', $ficheInfoPdf['ID']);
$ficheInfoEdition = get_field('brochure_edition', get_the_ID()); $ficheInfoEdition = get_field('brochure_edition', get_the_ID()) ?? null;
$thematique = get_the_terms(get_the_ID(), 'thematiques')[0]; $thematique = get_the_terms(get_the_ID(), 'thematiques')[0] ?? null;
$rootThematic = getParentThematique($thematique); $rootThematic = getParentThematique($thematique) ?? null;
$rootThematicIcon = get_field('taxonomy_pictures', "thematiques_" . $rootThematic->term_id)['icon'] ?? null; $rootThematicIcon = get_field('taxonomy_pictures', "thematiques_" . $rootThematic->term_id)['icon'] ?? null;
?> ?>
<li class="publications-grid__row"> <li class="publications-grid__row">
@ -26,7 +24,9 @@ $fichesInfosPosts = $args['fichesInfosPosts'];
<?php endif; ?> <?php endif; ?>
<div class="publications-grid__button"> <div class="publications-grid__button">
<a href="<?php echo $brochurePdf['url'] ?>" class=" cta cta--secondary cta--button" href="#" target="_blank"><?php echo __("Consulter le pdf", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?></a> <?php if ($ficheInfoPdf) : ?>
<a href="<?php echo $ficheInfoPdf['url'] ?>" class=" cta cta--secondary cta--button" href="#" target="_blank"><?php echo __("Consulter le pdf", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?></a>
<?php endif; ?>
</div> </div>
</li> </li>
<?php endwhile ?> <?php endwhile ?>