i have an issues in my code below.
In days and time i want to add a loop, it s because i want to be able to get multiple different operating hours row. I ll add a repeater in my custom field.
And for now it s allow me to get only one row.
<ul>
<?php foreach($locations as $location) {
$title = get_the_title($location);
$address = '';
$address .= get_field('address', $location) . '<br>';
$address .= get_field('city', $location) . ', ';
$address .= get_field('state', $location) . ', ';
$address .= get_field('zip_code', $location);
$hours = get_field('days_open', $location);
$phone = get_field('contact_number', $location);
$email = get_field('contact_email', $location);
?>
<li>
<h3><?php echo $title; ?></h3>
<address><?php echo $address; ?></address>
<?php if($phone) { ?>
<a href="tel:<?php echo $phone ?>"><?php echo $phone; ?></a>
<?php }; ?>
<?php if($email) { ?>
<a href="mailto:<?php echo $email ?>"><?php echo $email; ?></a>
<?php }; ?>
<?php
if($hours && $hours[0]['days']
) {
echo $hours[0]['days'] . ': ';
}
?>
<?php
if($hours && $hours[0]['times']
) {
echo $hours[0]['times'];
}
?>
</li>
<?php
}
?>
</ul>
So i think my solution it s to add a foreach loop, can you help for that?
Thank you in advance cheers!
2
Answers
So I found the solutions it was :
May be this is what you are looking for?