Print values
Print a text
On this page
You want: to show a text field (a headline, a name, a phone number) on your page.
How
<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
$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
| Function | Returns | Escaped? |
|---|---|---|
ugly_show() | Prints it | Yes, for the type of the field |
ugly_get() | The value (or null) | No: you do it |
Did this article answer your question?
Thank you. It helps us make the documentation better. Need more help?