Home › Forums › General Issues › Display selected relationship as a String › Reply To: Display selected relationship as a String
It was returning an ID, now I’ve changed it to return an object (in the Back-End) and also changed the code, previously I was receiving the following message:
Trying to get property of non-object in… (same as above).
The final code:
$query = new WP_Query($args);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
?>
<?php $i = 0;?>
<?php if($i == 0){ echo "<tr>"; }?>
<td>
<?php
$artista_evento = get_field('artista_del_evento');
foreach ($artista_evento as $av) {
echo get_the_title( $av->ID );
}
?>
</td>
<?php $i++;?>
<td><?php the_field('fecha_del_evento'); ?></td>
<?php $i++;?>
<td><?php the_field('lugar_del_evento'); ?></td>
<?php $i++;?>
<td><?php echo get_the_content(); ?></td>
<?php $i++;?>
<?php if($i == 4){ echo "</tr>"; $i=0;}?>
<?php endwhile; ?>
<?php if($i < 4) echo '</tr>'; ?>
</table>
<?php wp_reset_postdata(); ?>
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.