Hi I have a Post Object field in Advanced Custom Fields that I want to return a few posts sorted by date. I have user field data from these messages returning a fine, but Post Objects are returned in the order of the Post ID. I want them to be ordered by the publication date of publication.
<?php $post_objects = get_field('exhibitions'); if( $post_objects ): ?> <?php foreach( $post_objects as $post_object): ?> <a href="<?php echo get_permalink($post_object->ID); ?>"> <div style="display: inline-block"> <? if( get_field( 'title', $post_object->ID) ): ?> <em><?php the_field('title', $post_object->ID); ?></em><br> <?php endif; ?> <? if( get_field( 'dates', $post_object->ID) ): ?> <?php the_field('dates', $post_object->ID); ?> <?php endif; ?> </div> </a> <br><br> <?php endforeach; ?> <?php endif; ?>
This returns the custom text fields "title" and "date" from each column selected in the Post Objects field in the column where it is called.
I want messages to be returned here in order of publication date.
Any ideas?
source share