---
title: "Display Custom Fields (Meta)"
description: "Display custom meta fields saved by Lazy Blocks with get_lzb_meta(), including repeaters and images. With the plugin off, decode the raw value by hand."
url: "https://www.lazyblocks.com/docs/examples/display-custom-fields-meta/"
lastUpdated: 2026-09-23
source: "examples/display-custom-fields-meta.mdx"
---
# Display Custom Fields (Meta)

This guide explains how to display and manipulate custom meta fields created with Lazy Blocks in your WordPress theme or plugin.

Custom meta fields are primarily intended for developers. If you're new to custom fields, please review the [WordPress Custom Fields documentation](https://wordpress.org/documentation/article/assign-custom-fields/) first.

## Basic Meta Value Display

To display a simple meta value:

```php title="PHP"
<p>
    <?php echo get_lzb_meta('control_meta_name'); ?>
</p>
```

## Working with Meta Values

### Conditional Display

```php title="PHP"
if (get_lzb_meta('control_meta_name')) {
    ?>
    <p>The value is True</p>
    <?php
} else {
    ?>
    <p>The value is False</p>
    <?php
}
```

### Handling Array Data (e.g., Repeater Fields)

```php title="PHP"
$repeater = get_lzb_meta('control_meta_name');

foreach ($repeater as $inner_control) {
    ?>
    <p><?php echo esc_html($inner_control); ?></p>
    <?php
}
```

### Working with Image Fields

Display image with URL and alt text:

```php title="PHP"
$image = get_lzb_meta('control_meta_name');

if (isset($image['url'])) : ?>
    <img src="<?php echo esc_url($image['url']); ?>"
         alt="<?php echo esc_attr($image['alt']); ?>">
<?php endif; ?>
```

Display image using WordPress attachment functions:

```php title="PHP"
$image = get_lzb_meta('control_meta_name');

if (isset($image['id'])) {
    echo wp_get_attachment_image($image['id'], 'large');
}
```

## Manual Meta Data Handling

When Lazy Blocks plugin is not active but you need to access previously saved meta data, you'll need to manually decode the stored values.

Here's how to manually retrieve and decode meta values:

```php title="PHP"
// Get raw meta value from database
$meta_val = get_post_meta(get_the_ID(), 'meta_name', true);

if ($meta_val) {
    // Decode the stored meta value
    $meta_val = json_decode(rawurldecode($meta_val), true);

    // Use the decoded value
    var_dump($meta_val);
}
```

The `get_lzb_meta()` function automatically handles decoding of stored meta values. Only use the manual decoding method when the plugin is not available.

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