Support

Account

Home Forums Gutenberg Insert block when creating a new post

Solved

Insert block when creating a new post

  • Wouldn’t it be nice if some blocks would appear in the editor when adding a new post, page or other post type?
    For example, always start the page with a slideshow / cover block or Heading.

    Is there a way to “auto add” blocks inside a new post?

  • Got it!

    //add default blocks to the content
    function indewalvis_post_block_template() {
    	$post_type_object = get_post_type_object( 'page' );
    	$post_type_object->template = array(
    		array( 'acf/slideshow' ),
    		array( 'core/heading', array( 'level' => 1 ) ),
    		array( 'core/paragraph' ),
    	);
    }
    add_action( 'init', 'indewalvis_post_block_template' );
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.