---
title: "Select"
description: "Add Select control to your custom blocks for WordPress using the Lazy Blocks plugin."
url: "https://www.lazyblocks.com/docs/blocks-controls/select/"
lastUpdated: 2026-09-09
source: "blocks-controls/select.mdx"
---
# Select

Select control provides a dropdown menu with customizable options. It supports both single and multiple selections with flexible output formats.

## Control Settings

- **Choices** (`choices`) - a `Label` and a `Value` for each option, added with **+ Add Choice**. Empty by default
- **Allow Null** (`allow_null`) - off by default. On, a `-- Select --` option with an empty value is put at the top of the list, and a required Select accepts that empty value
- **Multiple** (`multiple`) - off by default. On, the dropdown accepts several options and the control stores an array
- **Output Format** (`output_format`) - `Value` by default:
  - `Value` - Returns option value
  - `Label` - Returns option label
  - `Both (Array)` - Returns both value and label

To add options, fill the Choices setting:

## Usage Examples

### Single Selection

```php title="PHP" /$attributes['control_name']/
<div class="layout-<?php echo esc_attr( $attributes['control_name'] ); ?>">
  Content
</div>
```

```hbs title="Handlebars" /{{control_name}}/
<div class="layout-{{control_name}}">
  Content
</div>
```

### Multiple Selection

```php title="PHP" /$attributes['control_name']/
<?php if ( $attributes['control_name'] ) : ?>
  <ul class="features">
    <?php foreach( $attributes['control_name'] as $value ): ?>
      <li class="feature-<?php echo esc_attr( $value ); ?>">
        <?php echo esc_html( $value ); ?>
      </li>
    <?php endforeach; ?>
  </ul>
<?php endif; ?>
```

```hbs title="Handlebars" /control_name/
{{#if control_name}}
  <ul class="features">
    {{#each control_name}}
      <li class="feature-{{this}}">{{this}}</li>
    {{/each}}
  </ul>
{{/if}}
```

### Array Output Format

```php title="PHP" /$attributes['control_name']/
<?php if ( $attributes['control_name'] ) : ?>
  <div class="option-<?php echo esc_attr( $attributes['control_name']['value'] ); ?>">
    <?php echo esc_html( $attributes['control_name']['label'] ); ?>
  </div>
<?php endif; ?>
```

```hbs title="Handlebars" /control_name/
{{#if control_name}}
  <div class="option-{{control_name.value}}">
    {{control_name.label}}
  </div>
{{/if}}
```

### Post Meta

```php title="Post Meta" /get_lzb_meta( 'control_meta_name' )/
<?php
$value = get_lzb_meta( 'control_meta_name' );
if ( $value ) {
    echo '<div class="option-' . esc_attr( $value ) . '">';
    echo esc_html( $value );
    echo '</div>';
}
?>
```

Use meaningful values that can work as CSS classes or conditional identifiers. For example: 'grid-layout', 'list-layout'.

## Documentation Index
> Fetch the complete documentation index at: https://www.lazyblocks.com/llms.txt
> Fetch every page in a single file at: https://www.lazyblocks.com/llms-full.txt
