Email

The Email field creates a simple text input that only accepts valid email addresses.

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.

PHP API Controls

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

Template Usage

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

<a href="mailto:<?php block_field( 'owners-email' ); ?>">Owner's Email</a>

The API will return the email as a string.

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

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

<p>Interested in this pet? <a href="mailto:<?php block_field( 'owners-email' ); ?>" />Contact the owner for more information!</a></p>

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