---
title: "Taxonomy"
description: "The Pro Taxonomy control picks category, tag or custom taxonomy terms as a slug, ID or WP_Term object. Turn a slug into a term with get_term_by()."
url: "https://www.lazyblocks.com/docs/blocks-controls/taxonomy/"
lastUpdated: 2026-09-23
source: "blocks-controls/taxonomy.mdx"
---
# Taxonomy [Pro]

Taxonomy control lets you search and select terms from any WordPress taxonomy (categories, tags, or custom taxonomies).

Only taxonomies registered with `show_in_rest => true` will appear in the control. If your custom taxonomy is not showing up, add this parameter:

```php
register_taxonomy('your_taxonomy', 'post', [
    // ... other parameters
    'show_in_rest' => true,
]);
```

## Control Settings

- **Taxonomy** (`taxonomy`) - where the terms come from, `category` by default. The list holds every taxonomy the REST API exposes
- **Appearance** (`taxonomy_appearance`) - `Select` by default, a searchable dropdown. `Radio` puts one input per term on screen and is labelled `Checkbox` while Multiple is on. `Token Field` takes terms as removable tokens
- **Output Format** (`taxonomy_output_format`) - what the control stores. `Term Slug` by default, or `Term ID`, or `Term Object`, which stores the ID and turns it into a `WP_Term` when the block renders
- **Multiple** (`multiple`) - off by default. Stores an array of terms instead of one

Output Format decides what is written into the block, not how an existing value is read, so blocks saved before you switch from `Term Slug` to `Term ID` keep their slugs until the term is picked again.

## Usage Examples

### Basic Usage (Term Slug)

```php title="PHP" /$attributes['control_name']/
<?php
$term = get_term_by('slug', $attributes['control_name'], 'category');
if ($term && !is_wp_error($term)) {
    echo '<span class="term">' . esc_html($term->name) . '</span>';
}
?>
```

### Multiple Terms

```php title="PHP" /$attributes['control_name']/
<?php if ($attributes['control_name']) : ?>
    <ul class="terms-list">
        <?php foreach($attributes['control_name'] as $term_slug) :
            $term = get_term_by('slug', $term_slug, 'category');
            if ($term && !is_wp_error($term)) : ?>
                <li class="term-<?php echo esc_attr($term->slug); ?>">
                    <?php echo esc_html($term->name); ?>
                </li>
            <?php endif;
        endforeach; ?>
    </ul>
<?php endif; ?>
```

### Using Term Object

```php title="PHP" /$attributes['control_name']/
<?php if ($attributes['control_name']) : ?>
    <div class="term-<?php echo esc_attr($attributes['control_name']->slug); ?>">
        <h4><?php echo esc_html($attributes['control_name']->name); ?></h4>
        <p><?php echo esc_html($attributes['control_name']->description); ?></p>
    </div>
<?php endif; ?>
```

### Handlebars Usage

Set Output Format to `Term Object` when using Handlebars templates.

```hbs title="Single Term" /control_name/
<div class="term-{{control_name.slug}}">
  {{control_name.name}}
</div>
```

```hbs title="Multiple Terms" /control_name/
<ul class="terms-list">
  {{#each control_name}}
    <li class="term-{{this.slug}}">
      {{this.name}}
    </li>
  {{/each}}
</ul>
```

### Post Meta

```php title="Post Meta" /get_lzb_meta( 'control_meta_name' )/
<?php
$term_slug = get_lzb_meta('control_meta_name');
if ($term_slug) {
    $term = get_term_by('slug', $term_slug, 'category');
    if ($term && !is_wp_error($term)) {
        echo '<span class="term">' . esc_html($term->name) . '</span>';
    }
}
?>
```

Use Term Object format to access all term data without additional database queries.

## 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
