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">
<?php if (has_post_thumbnail()) : ?>
<div class="card-img-top">
@ -13,40 +20,30 @@
</div>
<?php endif; ?>
<div class="card-body">
<h2 class="card-title">
<div class="post-card-dbmod__content">
<h2 class="post-card-dbmod__title">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h2>
<div class="card-text">
<?php the_excerpt(); ?>
</div>
<?php
// Afficher les champs ACF si présents
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 if ($modele) : ?>
<p class="modele">Modèle: <?php echo esc_html($modele); ?></p>
<?php endif; ?>
<?php if ($annee) : ?>
<p class="annee">Année: <?php echo esc_html($annee); ?></p>
<?php endif; ?>
</div>
<?php if ($author) : ?>
<p class="author">par :<?php echo esc_html($author); ?></p>
<?php endif; ?>
<div class="post-card-dbmod__details">
<?php if ($chapo) : ?>
<p class="chapo"><?php echo esc_html($chapo); ?></p>
<?php endif; ?>
<?php if ($content) : ?>
<p class="content"><?php echo esc_html($content); ?></p>
<?php endif; ?>
<?php if ($maitron_url) : ?>
<p class="maitron_url">Maitron URL: <?php echo esc_html($maitron_url); ?></p>
<?php endif; ?>
</div>
</div>
<div class="card-footer">