Text

The Text field creates a simple text input option for the block.

Settings

  • Help Text: Instructions to describe the data needed in the field.
  • Default Value: The default value for this field when adding the block.
  • Placeholder Text: The helper text which appears when the input is empty.
  • Character Limit: The maximum number of characters allowed to be entered.

PHP API Controls

  • name
  • label
  • control
  • type
  • order
  • location
  • width
  • help
  • default
  • placeholder
  • maxlength

Template Usage

To display the Text field in your template, use the field name you provided.

<?php block_field( 'pets-name' ); ?></p>

The API will return the text as a string.

Example template file /blocks/block-block-lab-example.php

<?php
// Block Lab Example Text Field
?>

<h3>Pet's Name:</h3>
<p><?php block_field( 'pets-name' ); ?></p>

To use the block with the Text field on your site, locate it in the blocks menu.

Screenshot showing the Block Lab custom block in the menu

It will then display within your post/page.

And on the front-end of your site.