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

Print values

Print a text

1 minute to read Updated 1 week ago

On this page

You want: to show a text field (a headline, a name, a phone number) on your page.

How

PHP
<h1><?php ugly_show( 'headline' ); ?></h1>

ugly_show() prints the value already escaped for its type: you do not choose between esc_html(), esc_url() and wp_kses_post() on every line.

When you need the value in code

PHP
$headline = ugly_get( 'headline' );
if ( $headline ) {
	echo '<h1>' . esc_html( $headline ) . '</h1>';
}

ugly_get() gives the raw value, so you escape it. Use it to compare, to build a string or to pass the value to another function.

What you get

FunctionReturnsEscaped?
ugly_show()Prints itYes, for the type of the field
ugly_get()The value (or null)No: you do it

Did this article answer your question?