Support

Account

Home Forums Add-ons Repeater Field sort by publication date the relationship sub field rows into repeater

Unread

sort by publication date the relationship sub field rows into repeater

  • hi.
    Hi have a repeater field that has a sub field that is a relationship.
    Does anyone know how to display the sort of this by the relationship post date reverse order (from the newest to de oldest).

    That’s the current code to display it and it works properly:

    <?php if( have_rows('articoli') ): ?>
    <?php while( have_rows('articoli') ): the_row();
    // vars
    $posts = get_sub_field('articolo_premiato');
    $annata = get_sub_field('annata');
    $valutazione = get_sub_field('punteggio');
    ?>
    <?php if( $posts ): ?>
    <div class="col-sm-4 sfondo-box-premi">
    <?php foreach( $posts as $p ): // variable must NOT be called $post (IMPORTANT) ?>
    <div class="row box-premiazioni ">
    <div class="col-sm-12">
    <?php echo '<a href="' . get_permalink( $p->ID ) . '" >';
    echo get_the_post_thumbnail( $p->ID, 'thumbnail', array('class' => 'immagine-box btn-shad btn-hover-shad') );
    echo '</a>';
    ?>
    </div>
    </div>
    <div class="row box-premiazioni">
    <div class="col-sm-12 testo-box-premi">
    <h3><a href="<?php echo get_permalink( $p->ID ); ?>"><?php echo get_the_title( $p->ID ); ?></a></h3>
    </div>
    </div> 
    <?php endforeach; ?>
    <div class="row box-annata">
    <div class="col-sm-12 testo-box-annata">
    <h4><?php echo $valutazione; ?></h4>
    <h5>ANNATA&ensp;<b><?php echo $annata; ?></b></h5>
    </div>
    </div>
    </div>
    <?php endif; ?>
    <?php endwhile; ?>
    <?php endif; ?>
    

    thank you

Viewing 1 post (of 1 total)

The topic ‘sort by publication date the relationship sub field rows into repeater’ is closed to new replies.