Skip to content
Custom fields for WordPress that are quick to build and quick to load. Get Pro
Docs

Print values

Loop over a repeater

1 minute to read Updated 1 week ago

PHP
<ul>
	<?php foreach ( ugly_rows( 'team' ) as $person ) : ?>
		<li>
			<?php $person->show( 'name' ); ?>
			<?php if ( $person->has( 'role' ) ) : ?>
				<em><?php $person->show( 'role' ); ?></em>
			<?php endif; ?>
		</li>
	<?php endforeach; ?>
</ul>

ugly_rows() always gives a list, empty when there is nothing, so no if is needed around the loop. A row is a variable: pass it to get_template_part( 'parts/person', null, array( 'person' => $person ) ).

Did this article answer your question?