Radio

The Radio field creates an input option for the block. Multiple items cannot be selected.

Settings

  • Help Text: Instructions to describe the data needed in the field.
  • Choices: The available items in the list.
    • Enter each choice on a new line.
    • To specify the value and label separately, use this format: value : Label.
  • Default Value: The default value for this field when adding the block.

PHP API Controls

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

Template Usage

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

<p>Species: <?php block_field( 'species' ); ?></p>

The API will return the value as a string.

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

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

<h3>What species is this pet?</h3> 
<p><?php block_field( 'species' ); ?></p>

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