I want to retrieve all the repeater rows that contain a specific subfield. I have a variable date field defined as follows :
$journey_value = $_GET['onward-date'] != '' ? $_GET['onward-date'] : '';
The “event_bus_date” is also a date field and both $journey_value and event_bus_date are in same date format.I have the following code but it displays nothing :
<?php if( have_rows('event_instance') ): ?>
<ul>
<?php while( have_rows('event_instance') ): the_row(); ?>
<?php if($journey_date == the_sub_field('event_bus_date')) { ?>
<li><?php the_sub_field('event_bus_date'); ?></li>
<?php } ?>
<?php endwhile; ?>
</ul>
<?php endif; ?>
Please help to find the error in the code! Thank you
the_field() and the_sub_field() are only used to output the value on the page and they do not return the value.
use get_field() or get_sub_field()
<?php if($journey_date == get_sub_field('event_bus_date')) { ?>