Support

Account

Home Forums ACF PRO Agenda d’évènements avec ACF ( dates )

Helping

Agenda d’évènements avec ACF ( dates )

  • 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 class="year"><?php echo $year; ?>
    
                        </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

  • It is impossible to show a post more than once using WP_Query and a basic WP loop. This requires that every post listed be a unique post.

    See my advice here https://support.advancedcustomfields.com/forums/topic/helping-planning-acf-project/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.