REFACTOR Update content-dbmod template to include ACF fields and improve structure

This commit is contained in:
Antoine 2025-05-12 16:53:38 +02:00
parent d78ae8937d
commit 9d7127c123

View File

@ -5,7 +5,14 @@
*/ */
?> ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('dbmod-item'); ?>> <?php
$chapo = get_field('chapo');
$content = get_field('content');
$author = get_field('author');
$maitron_url = get_field('maitron_url');
?>
<article id="post-<?php the_ID(); ?>" <?php post_class('post-card-dbmod'); ?>>
<div class="card h-100"> <div class="card h-100">
<?php if (has_post_thumbnail()) : ?> <?php if (has_post_thumbnail()) : ?>
<div class="card-img-top"> <div class="card-img-top">
@ -13,40 +20,30 @@
</div> </div>
<?php endif; ?> <?php endif; ?>
<div class="card-body"> <div class="post-card-dbmod__content">
<h2 class="card-title"> <h2 class="post-card-dbmod__title">
<a href="<?php the_permalink(); ?>"> <a href="<?php the_permalink(); ?>">
<?php the_title(); ?> <?php the_title(); ?>
</a> </a>
</h2> </h2>
<div class="card-text"> <?php if ($author) : ?>
<?php the_excerpt(); ?> <p class="author">par :<?php echo esc_html($author); ?></p>
</div> <?php endif; ?>
<div class="post-card-dbmod__details">
<?php <?php if ($chapo) : ?>
// Afficher les champs ACF si présents <p class="chapo"><?php echo esc_html($chapo); ?></p>
if (function_exists('get_field')) :
// Exemple d'affichage de champs ACF
$marque = get_field('marque');
$modele = get_field('modele');
$annee = get_field('annee');
?>
<div class="dbmod-details">
<?php if ($marque) : ?>
<p class="marque">Marque: <?php echo esc_html($marque); ?></p>
<?php endif; ?> <?php endif; ?>
<?php if ($modele) : ?> <?php if ($content) : ?>
<p class="modele">Modèle: <?php echo esc_html($modele); ?></p> <p class="content"><?php echo esc_html($content); ?></p>
<?php endif; ?> <?php endif; ?>
<?php if ($annee) : ?> <?php if ($maitron_url) : ?>
<p class="annee">Année: <?php echo esc_html($annee); ?></p> <p class="maitron_url">Maitron URL: <?php echo esc_html($maitron_url); ?></p>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php endif; ?>
</div> </div>
<div class="card-footer"> <div class="card-footer">