---
title: "Custom Post Type and Save in Meta control"
description: "Learn how to create custom blocks with Meta fields for Custom Post Types using the Lazy Blocks WordPress plugin."
url: "https://www.lazyblocks.com/docs/examples/custom-post-type-and-save-in-meta-control/"
lastUpdated: 2025-02-24
source: "examples/custom-post-type-and-save-in-meta-control.mdx"
---
# Custom Post Type and Save in Meta control

When implementing blocks with the `Save in Meta` option in Custom Post Types, it's crucial to ensure your post type properly supports custom fields. This guide explains how to set up Custom Post Types correctly for use with Lazy Blocks meta fields.

## Registering Custom Post Type

Here's how to register a Custom Post Type with proper support for both the block editor and meta fields:

```php title="PHP"
function create_my_custom_post_type() {
    register_post_type(
        'my_custom_post',
        array(
            'labels' => array(
                'name'          => __('My Custom Post'),
                'singular_name' => __('My Custom Post')
            ),
            'public' => true,

            // Enable Gutenberg editor support
            'show_in_rest' => true,

            'supports' => array(
                'title',
                'editor',
                'thumbnail',
                // Enable custom meta fields support
                'custom-fields',
            ),
        )
    );
}
add_action('init', 'create_my_custom_post_type');
```

## Important Considerations

- Always include `show_in_rest => true` to ensure compatibility with the block editor
- Add `custom-fields` to the supports array to enable meta field functionality
- Register your Custom Post Type early in the WordPress initialization process using the `init` hook

Without proper custom-fields support, blocks with the "Save in Meta" option will not function correctly in your Custom Post Type.

This setup ensures your Custom Post Type works seamlessly with Lazy Blocks' meta field features while maintaining full compatibility with the WordPress block editor.

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