# Block Template for New Posts

> Starts every new post with a set of placeholder blocks, such as a summary paragraph, a heading and an image, so writers follow the same structure.

- Type: PHP
- Runs: Run everywhere
- Category: [Block Editor](https://wpide.com/library/category/gutenberg/)
- Tags: templates, blocks, editor
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/block-template-for-new-posts/

## Code

```php
// Post type that gets the template.
$wpide_template_post_type = 'post';
// Blocks and their attributes.
$wpide_template_blocks = array(
    array( 'core/paragraph', array( 'placeholder' => 'Summarize the post in one or two sentences...' ) ),
    array( 'core/heading', array( 'level' => 2, 'placeholder' => 'First section heading' ) ),
    array( 'core/paragraph', array( 'placeholder' => 'Write the first section...' ) ),
    array( 'core/image', array() ),
);
// false, 'insert' or 'all'.
$wpide_template_lock = false;

add_action( 'init', function () use ( $wpide_template_post_type, $wpide_template_blocks, $wpide_template_lock ) {
    $object = get_post_type_object( $wpide_template_post_type );

    if ( ! $object ) {
        return;
    }

    $object->template = $wpide_template_blocks;

    if ( $wpide_template_lock ) {
        $object->template_lock = $wpide_template_lock;
    }
}, 20 );
```

## Notes

Change the post type, the blocks and the lock. Lock 'insert' stops blocks being added or removed; 'all' also stops moving them.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Block Template for New Posts" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
