```
--------------------------------
### Add Field to Existing Block (PHP)
Source: https://context7.com/studiopress/genesis-custom-blocks/llms.txt
Demonstrates how to add a new field to an already registered block using the `add_field` function. This is useful for modular block definitions or extending blocks defined elsewhere. Fields can be configured with labels, controls, order, and specific settings. This function also needs to be called within the `genesis_custom_blocks_add_blocks` action hook.
```php
'Company Name',
'control' => 'text',
'order' => 3,
]);
add_field( 'testimonial', 'featured', [
'label' => 'Featured Testimonial',
'control' => 'toggle',
'order' => 5,
'settings' => [
'default' => false,
],
]);
// Add a select field with predefined choices
add_field( 'testimonial', 'style', [
'label' => 'Display Style',
'control' => 'select',
'order' => 6,
'settings' => [
'options' => [
'card' => 'Card Layout',
'inline' => 'Inline Quote',
'fullwidth' => 'Full Width Banner',
],
'default' => 'card',
],
]);
});
```
--------------------------------
### Inner Blocks Control for Nesting (PHP)
Source: https://context7.com/studiopress/genesis-custom-blocks/llms.txt
Allows nesting of other Gutenberg blocks inside a custom block. It uses the 'inner_blocks' control type. The content of inner blocks is automatically rendered in the template.
```php
'Content Area',
'control' => 'inner_blocks',
'settings' => [
'help' => 'Add blocks inside this container',
],
]);
// In template (inner blocks content is automatically rendered)
// The inner blocks content is available through the template automatically
?>
```
--------------------------------
### Checkbox Input Field (PHP)
Source: https://context7.com/studiopress/genesis-custom-blocks/llms.txt
Adds a single checkbox that returns a boolean true/false value. It uses the 'checkbox' control type and demonstrates checking the value in the template.
```php
'Mark as Featured',
'control' => 'checkbox',
'settings' => [
'default' => false,
],
]);
// In template:
if ( block_value( 'is-featured' ) ) {
echo '
Featured';
}
?>
```
--------------------------------
### Range Control for Block Fields
Source: https://context7.com/studiopress/genesis-custom-blocks/llms.txt
Adds a slider input for selecting numeric values within a specified range. The selected integer value can be used for dynamic styling or layout adjustments.
```php
'Number of Columns',
'control' => 'range',
'settings' => [
'min' => 1,
'max' => 6,
'step' => 1,
'default' => 3,
'help' => 'Set the grid column count',
],
]);
// In template:
$columns = block_value( 'columns' ); // Returns integer between 1-6
?>
```
--------------------------------
### Output Block Field Value (PHP)
Source: https://context7.com/studiopress/genesis-custom-blocks/llms.txt
Outputs or returns a block field value. By default, it echoes the escaped value. Setting the second parameter to false returns the raw value.
```php
```
--------------------------------
### Email Input Field with Validation (PHP)
Source: https://context7.com/studiopress/genesis-custom-blocks/llms.txt
Adds an email input field to a block with validation. It uses the 'email' control type and demonstrates how to retrieve and validate the email value in the template.
```php
'Contact Email',
'control' => 'email',
'settings' => [
'placeholder' => 'email@example.com',
],
]);
// In template:
$email = block_value( 'contact-email' );
if ( is_email( $email ) ) : ?>
Contact Us
```
--------------------------------
### Radio Button Group Control (PHP)
Source: https://context7.com/studiopress/genesis-custom-blocks/llms.txt
Adds a radio button group for mutually exclusive single selection. It uses the 'radio' control type and allows defining options and a default value. The selected value is retrieved in the template.
```php
'Text Alignment',
'control' => 'radio',
'settings' => [
'options' => [
'left' => 'Left',
'center' => 'Center',
'right' => 'Right',
],
'default' => 'left',
],
]);
// In template:
$alignment = block_value( 'alignment' );
?>
?>
```
--------------------------------
### Modify Available Blocks with genesis_custom_blocks_available_blocks
Source: https://context7.com/studiopress/genesis-custom-blocks/llms.txt
This filter enables modification of the block list before they are registered with WordPress. It receives an array of blocks and can be used to hide blocks from specific user roles or alter block configurations, such as adding keywords.
```php
```
--------------------------------
### Retrieve Raw Block Field Value (PHP)
Source: https://context7.com/studiopress/genesis-custom-blocks/llms.txt
Returns the raw value of a block field without echoing it, allowing for custom processing and transformations.
```php
```
--------------------------------
### Modifying Field Values with Filters (PHP)
Source: https://context7.com/studiopress/genesis-custom-blocks/llms.txt
Modifies field values before they are output in templates using the 'genesis_custom_blocks_field_value' filter. This is useful for transformations, such as applying a CDN to image URLs or sanitizing textarea output.
```php
```
--------------------------------
### Add Custom Block Fields with genesis_custom_blocks_default_fields
Source: https://context7.com/studiopress/genesis-custom-blocks/llms.txt
This filter allows you to add custom attributes to Genesis Custom Blocks that can be accessed using the `block_field()` function. It takes an array of default fields and the block name as arguments. You can add new fields by assigning them a data type (e.g., 'string').
```php
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.