# The same page, in code

> The best way to see the difference is a small, real job: a team list on an "About" page.

Source: https://uglydev.com/docs/why-uglyfields/the-same-page-in-code/
Updated: 18 November 2026

## With the usual setup

```php
<?php if ( have_rows( 'team' ) ) : ?>
	<ul>
		<?php while ( have_rows( 'team' ) ) : the_row(); ?>
			<li>
				<h3><?php echo esc_html( get_sub_field( 'name' ) ); ?></h3>
				<p><?php echo esc_html( get_sub_field( 'role' ) ); ?></p>
			</li>
		<?php endwhile; ?>
	</ul>
<?php endif; ?>
```

There is a hidden "current row". Call a function that also loops, and the cursor is gone. Forget one `esc_html()` and you have a hole.

## With UglyFields

```php
<ul>
	<?php foreach ( ugly_rows( 'team' ) as $person ) : ?>
		<li>
			<h3><?php $person->show( 'name' ); ?></h3>
			<p><?php $person->show( 'role' ); ?></p>
		</li>
	<?php endforeach; ?>
</ul>
```

- No `if`: `ugly_rows()` always gives a list, empty when there is nothing.
- `$person` is a variable. Pass it to `get_template_part()` or to your own function.
- `show()` escapes for the type of field.

The functions are listed in [Reference: functions](https://uglydev.com/docs/functions/).
