Blocks
Examples
On this page
A call to action
ugly-blocks/cta/render.php:

<?php
$link = $block->get( 'button' ); // a link field
?>
<aside <?php echo get_block_wrapper_attributes( array( 'class' => 'cta' ) ); // phpcs:ignore WordPress.Security.EscapeOutput ?>>
<h2><?php $block->show( 'heading' ); ?></h2>
<p><?php $block->show( 'text' ); ?></p>
<?php if ( $link ) : ?>
<a class="button" href="<?php echo esc_url( $link['url'] ); ?>">
<?php echo esc_html( $link['title'] ); ?>
</a>
<?php endif; ?>
</aside>A pricing plan with a repeater of features

<div <?php echo get_block_wrapper_attributes( array( 'class' => 'plan' ) ); // phpcs:ignore WordPress.Security.EscapeOutput ?>>
<h3><?php $block->show( 'name' ); ?></h3>
<p class="plan__price"><?php $block->show( 'price' ); ?></p>
<ul>
<?php foreach ( $block->rows( 'features' ) as $feature ) : ?>
<li><?php $feature->show( 'label' ); ?></li>
<?php endforeach; ?>
</ul>
</div>A section that holds other blocks Pro
<section <?php echo get_block_wrapper_attributes( array( 'class' => 'section' ) ); // phpcs:ignore WordPress.Security.EscapeOutput ?>>
<?php if ( $block->has( 'title' ) ) : ?>
<h2><?php $block->show( 'title' ); ?></h2>
<?php endif; ?>
<div class="section__content">
<?php ugly_inner_blocks(); ?>
</div>
</section>Did this article answer your question?
Thank you. It helps us make the documentation better. Need more help?