I have a repeater with two sub-fields
1. A relationship field which points to a CPT
2. A date and time field
I am using the following code in post’s single.php to output these values
<?php
$rows = get_field('theatre');
if($rows)
{
echo '<ul>';
foreach($rows as $row)
{
echo '<li>sub_field_1 = ' . $row['theatre_name'] . ', sub_field_2 = ' . $row['start_date'] .', etc</li>';
}
echo '</ul>';
}
?>
This is the output I get.
sub_field_1 = Array, sub_field_2 = 2/14/14 5:00 pm, etc
sub_field_1 = Array, sub_field_2 = 2/15/14 1:00 pm, etc
Could you guide me on how to get the value for that array instead of just “Array” and also how to make a hyperlink to that CPT ?
Thanks
Hi @sri
Something like this would work:
<?php
$theatre = $row['theatre_name'];
$theatre = current($theatre);
echo '<li>sub_field_1 = ' . get_the_title($theatre->ID) . ', sub_field_2 = ' . $row['start_date'] .', etc</li>';
?>
Please remember that the relationship will return an array of post objects.
Thanks
E