Bonjour à tous
Aujourd’hui j’affiche sur mon wordpress une liste de Post avec une date ACF et ma liste s’affiche parfaitement avec une date;
<?php $query = new WP_Query ( array (
'post_type' => 'post',
'ignore_sticky_posts' =>1,
'facetwp' => true,
'meta_key' => 'agenda',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' =>
array(
array(
'key' => 'agenda',
'value' => date('Ymd', current_time('timestamp')),
'compare' => '>=',
'type' => 'NUMERIC,'
)
),
)) ; ?>
<?php if ( $query -> have_posts ()) : while ( $query -> have_posts ()) : $query -> the_post (); ?>
<div class="col-12 MB20">
<div class="row row-agenda">
<!-- DATE -->
<div class="col-md-2 col-4 padding15">
<div class="date-agenda text-center">
<?php
$date = get_field('agenda');
$unixtimestamp = strtotime( $date );
$day = date_i18n( "d", $unixtimestamp );
$month = date_i18n( "F", $unixtimestamp );
$year = date_i18n( "Y", $unixtimestamp );
?>
<span class="day"><?php echo $day; ?></span>
<p class="month"><?php echo $month; ?></p>
<p class="year"><?php echo $year; ?></p>
</div>
</div>
<!-- INFOS -->
<div class="col-md-10 col-8">
<div class="lat-course-content">
<div class="lat-course-title">
<h5><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h5>
</div>
<div class="lat-course-meta">
<span><i class="far fa-calendar-alt"></i>Prochaine date : <?php the_field('date_mises_en_avant'); ?></span>
<span><i class="far fa-clock"></i><?php the_field('duree'); ?></span>
<div>
<span><i class="fas fa-map-marker-alt"></i><?php the_field('lieu'); ?></span>
<span><i class="fas fa-book"></i> <?php foreach ( get_the_terms( get_the_ID(), 'domaines_formations' ) as $term ) { echo '<span>' . $term->name . '</span>'; } ?></span>
<span><i class="fas fa-book"></i> <?php foreach ( get_the_terms( get_the_ID(), 'domaines_intervention' ) as $term ) { echo '<span>' . $term->name . '</span>'; } ?></span>
</div>
</div>
<div class="lire-suite-blog">
<span><i class="orangeFont fas fa-eye"></i> <i><a style="font-size: 14px" href="<?php echo get_permalink(); ?>" class="orangeFont">En savoir plus</a></i></span>
</div>
</div>
</div>
</div>
</div>
<?php endwhile ; endif ; ?>
Mais j’aimerai entré plusieures dates dans chaque post et faire s’afficher la liste dans l’ordre chronologique ( même comportement que boucle de base ) . J’ai essayé avec les champs repeter ACF mais impossible car parfois un post peut s’afficher plusieurs fois dans la liste si plusieures dates lui sont attribuées.
Quelle méthode je pourrai utiliser autre que ACF repeter ?
Ou alors j’ai raté quelquechose avec ACF repeter : c’est peut être possible quand même ?
Merci de votre aide 🙂
Tony
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.