According to this documentation, the return value for have_rows()
is bool
. So if a row exists, it returns true
. Which totally makes sense. In case if there aren’t any rows, it’s suppose to return false
right?
However, that is not the case. It returns an empty string if there aren’t any rows.I had to exit early from the code. So I found out that only the following works.
if ( '' === have_rows( 'event_dates', $published_event ) ) {
return;
}
Thoughts?
if (!have_rows('event_dates'))
should do the same thing.
The function returns a truthy or falsey value.
I your case it is likely returning an empty string because the repeater was never set to any value, but that is just a guess.