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

Blocks

Examples

1 minute to read Updated 1 week ago

On this page

A call to action

ugly-blocks/cta/render.php:

The call to action block on a page of the site
The call to action block on a page of the site.
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

The pricing plan block on the site, with its list of features
The pricing plan block on the site, with its list of features.
PHP
<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

PHP
<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?