The Number field creates an input area that only accepts numbers.


  • Help Text: Instructions to describe 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.

PHP API Controls

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

Template Usage

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

<?php block_field( 'adoption-fee' ); ?>

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

// Block Lab Example Number Field 

<p>Adoption Fee: <?php block_field( 'adoption-fee' ); ?></p> 

To use the block with the Number 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.

The API will return an integer, and echo a string.

// Block Lab Example Number Field 
<p>Adoption Fee: $<?php block_field( 'adoption-fee' ); ?></p> 

At a dollar a hug, your new best friend brings smiles and 
      for( $i = 1; $i <= block_value( 'adoption-fee' ); $i++ ) {
        echo ' and hugs';