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.
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.
<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 write | You get |
|---|---|
ugly_get( 'title' ) | The value of the field of this block |
ugly_show( 'title' ) | The same, printed and escaped |
$block | The 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?
Thank you. It helps us make the documentation better. Need more help?