Hello,
I’m trying to get select field label not value. I’m using code which sorts by date and removes if date is =< today. If i’m using that “get label” part with standart repeater loop it works, but with this custom loop it doesn’t.
Any help here?
<?php
$currDate = date("Ymd");
$repeater = get_field('routes');
foreach( $repeater as $key => $row )
{
$column_id[ $key ] = $row['departure_date'];
}
array_multisort( $column_id, SORT_ASC, $repeater );
foreach( $repeater as $row ) :
{
$date = DateTime::createFromFormat('Ymd', $row['departure_date']);
if ($currDate != $date->format('Ymd')) :
{
$selectFrom = get_sub_field_object('from_city');
$valueFrom = get_sub_field('from_city');
$fromCity = $selectFrom['choices'][ $valueFrom ];
?>
<p><?php echo $fromCity; ?><p>
<?php }endif; } endforeach; ?>
When you use a block with “:” don’t need use {} too.
if( condition… ) : code… endif;
while( condition… ) : code… endwhile;
I don’t know if it help you, but is a start