I display related information of another custom post by using related field in the loop. Here is the code.
<?php
$args = array(
'post_type' => 'gallery',
'posts_per_page' => 12,
'paged' => $paged,
'post_status' => 'publish',
'orderby' => 'post_date',
'order' => 'DESC',
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
?>
<div class="article-list row">
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="article-list__item col-lg-4 col-sm-6 col-12 d-flex">
<a href="<?php the_permalink(); ?>" class="article-list__link outer-link">
<?php
$posts = get_field('relationship_field');
if( $posts ): ?>
<?php foreach( $posts as $post): ?>
<div class="article-list__thumb thumb-anim">
<div class="article-list__number d-flex align-items-center justify-content-center"><span><?php $images = get_field('image'); echo count( $images ); ?></span></div>
<?php
$attachment_id = get_field('thumbnail');
$image_src = wp_get_attachment_image_src( $attachment_id, 'full' );
$attachment = get_post( get_field('thumbnail') );
$alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
$title = $attachment->post_title;
?>
<img class="fluid of-cover" src="<?php echo $image_src[0]; ?>" width="<?php echo $image_src[1]; ?>" height="<?php echo $image_src[2]; ?>" alt="<?php echo $alt; ?>" title="<?php echo $title; ?>">
</div>
<div class="article-list__detail">
<h3 class="article-list__title"><span class="g-title--primary d-block">VS: <?php the_title(); ?></span>
<span class="g-title--secondary d-block"><?php the_field('date'); ?></span></h3>
</div>
<?php endforeach; endif; ?>
<time class=”article-list__date”><?php echo get_post_time(‘Y.m.d D’); ?></time>
</div>
<?php endwhile; wp_reset_postdata(); ?>
<!–/.article-list–></div>
<?php endif; ?>`
I want to display the submission date, but if it is the above method, posting date of the post selected in relation field will be displayed.
Post type: gallery
Post type selected from relation field: match-results
Posted on: match-results
How can I display the contribution date of gallery?