# ugly_get() or ugly_show()?

> They are the same pair as get_field() and the_field() of ACF.

Source: https://uglydev.com/docs/php-api/ugly-get-or-ugly-show/
Updated: 19 November 2026

|  | `ugly_get( 'title' )` | `ugly_show( 'title' )` |
| --- | --- | --- |
| **What it does** | **Gives** the value as it was saved | **Prints** the value, made safe |
| **Use it to** | Compare it, loop over it, pass it to another function | Show something in a template |
| **Escaping** | None. You escape where it matters (`esc_html`, `esc_url`, `esc_attr`) | Done for you, by the type of the field |

> **Rule of thumb:** to show something, use `ugly_show()`. To decide something, use `ugly_get()`.

## What "safe" means in `ugly_show()`

It picks the right way for each kind of field, so you cannot forget it:

- **Text and text area** keep their `<br>`, `<strong>` and the other tags that WordPress allows in a post, and lose what runs (`<script>`, `onclick`).
- **Addresses** are escaped as addresses. **Numbers** as numbers.
- **Rich text** is printed as the HTML WordPress would print for a post.
- **A table** prints a `<table>`.

```php
<h1><?php ugly_show( 'heading' ); ?></h1>

<?php if ( ugly_get( 'show_banner' ) ) : ?>
	<p><?php ugly_show( 'banner_text' ); ?></p>
<?php endif; ?>
```

## What `ugly_get()` does not do

Text and text area fields keep what was typed, like ACF. So a `<br>` or a `<strong>` is still there, and `echo ugly_get( 'title' )` prints it. A text area with **Line breaks** set already has its `<br>` or `<p>`. Nothing is escaped:

```php
// In an attribute, escape it yourself.
<a href="<?php echo esc_url( ugly_get( 'website' ) ); ?>" title="<?php echo esc_attr( ugly_get( 'tooltip' ) ); ?>">
```
