• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Genesis Custom Blocks

Genesis Custom Blocks

Create effective content faster.

  • Need Help?
You are here: Home / Functions / block_field()

block_field()

Description

The block_field() function outputs the value of a field you have created with Genesis Custom Blocks.

block_field( $name, $echo = true );

Note: If the supplied $name doesn’t exist, block_field() will return null.

Parameters

  • $name (string) (Required) The field name
  • $echo (bool) (Optional) Whether the value should be formatted and output, or returned as a variable.

Usage

In this example, display the value of a field as text in your template.

<p><?php block_field( 'testimonial' ); ?></p>

In this example, return the value of a field for further use without displaying it.

$author_name = block_field( 'author', false );

In this example, check to see if the value of the field is set.

$url = block_field( 'url', false );

if ( ! empty( $url ) ) {
    echo '<a href="' . $url . '">Click me!</a>';
}

Primary Sidebar

Get Started

  • Install Genesis Custom Blocks (free)
  • Install Genesis Custom Blocks Pro
  • Update Genesis Custom Blocks Pro
  • General Settings and Options

Create Custom Blocks

  • Create Your First Custom Block
  • Example Custom Block
  • Add a Custom Block to Your Website Content
  • Style Your Custom Blocks

Export and Import Custom Blocks

  • Export Custom Blocks to Include in Your Theme

Code References

  • Fields
  • Functions
  • Filters

Tutorials & FAQs

  • Tutorials
  • FAQs

Resources

  • Changelog
  • Block Lab Hook Compatibility
  • Block Lab PHP API Compatibility
  • Support

© 2013–2025 WPEngine, Inc. All rights reserved. WP ENGINE®, VELOCITIZE®, TORQUE®, EVERCACHE®, and the cog logo service marks are owned by WPEngine,Inc.
1WP Engine is a proud member and supporter of the community of WordPress® users. The WordPress® trademarks are the intellectual property of the WordPress Foundation, and the Woo® and WooCommerce® trademarks are the intellectual property of WooCommerce, Inc. Uses of the WordPress®, Woo®, and WooCommerce® names in this website are for identification purposes only and do not imply an endorsement by WordPress Foundation or WooCommerce, Inc. WP Engine is not endorsed or owned by, or affiliated with, the WordPress Foundation or WooCommerce, Inc.