Block Lab is a plugin that allows you to create custom blocks within the WordPress Gutenberg editor. You can create blocks for content or code that you repeatedly use in an effort to simplify publishing. To create a custom plugin, you will need to create a block first. Once you named a block, you can add fields to that block and pass the variables to the block templates. The template contains the code that you need to send to the Gutenberg editor in the form of blocks. Here’s an example of a Block and Template.

My Custom Block

![](https://uly.me/wp-content/uploads/2019/01/block-lab.png)
Custom block

Template: block-my-custom-block.php

The “block_field” function echoes the variables passed from the blocks to the template.

<pre lang="bash">
<h4><?php block_field( 'heading' )??></h4>

In some instances, you may have to mute the echo. In this example, I’m using the function in a comparison.

<pre lang="bash">
<h4><?php if (block_field( 'heading', $echo = false ) == ""):
 else: block_field( 'heading' ); endif; ??></h4>