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

Print values

Print only if there is something

1 minute to read Updated 1 week ago

You want: to draw a block of the page only if the editor wrote something, so there is no empty heading or button.

How

PHP
<?php if ( ugly_get( 'subtitle' ) ) : ?>
	<h2><?php ugly_show( 'subtitle' ); ?></h2>
<?php endif; ?>

ugly_get() gives null when the field does not exist for that page, and an empty value when it exists and is empty. Both are false in an if.

Inside a row

PHP
<?php if ( $row->has( 'subtitle' ) ) : ?>
	<h2><?php $row->show( 'subtitle' ); ?></h2>
<?php endif; ?>

Did this article answer your question?