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

The PHP API

Inside a block

In the render file of a block, ugly_get() and ugly_show() read the fields of that block. $block holds them as one row. More in Blocks.

1 minute to read Updated 1 week ago

Inside the template of a block (render.php) the fields are the fields of that block: you do not say which post they come from.

PHP
<section class="hero">
	<?php if ( ugly_get( 'title' ) ) : ?>
		<h2><?php ugly_show( 'title' ); ?></h2>
	<?php endif; ?>

	<ul>
	<?php foreach ( ugly_get( 'points' ) as $point ) : ?>
		<li><?php $point->show( 'text' ); ?></li>
	<?php endforeach; ?>
	</ul>
</section>

What you have inside

You writeYou get
ugly_get( 'title' )The value of the field of this block
ugly_show( 'title' )The same, printed and escaped
$blockThe fields of the block as one row: $block->show(), get(), has()
foreach ( ugly_get( 'points' ) …The rows of a repeater of the block

Did this article answer your question?