Home Forums Gutenberg Block template


Block template

    • Noraly

    • April 16, 2020 at 5:08 am


    Hope someone can help me with the following. I’m trying to make a blocks template in my functions.php.

    I can add the acf/myblock without any problems, but can’t seem to fill the fields in data. How can I do that?


    • NickDA

    • April 16, 2020 at 8:59 am

    Your question is not clear. Did you register your block to start in the preview mode? Then, when you load the block, you need to switch to edit mode. Or, if you registered the block in auto mode, then simply click on the block to automatically change it to the edit mode. Are you talking about having default values? You do that in the Field Groups when creating the fields… I can go on and on…

    P.S Clicking the pencil icon on the toolbar will change the mode to edit, and when you click on the Monitor icon next, you will go back from the edit mode to the preview mode.

    Follow the example found on this page:

    and continue reading this:

    I hope you can solve your issues !

    • Noraly

    • April 16, 2020 at 3:54 pm

    No i’m making a block template. So when the admin is creating a new page the prefered blocks are already there with the required settings already set. See link in original question.

    Now the placement of the blocks core and acf is working when I click on new page, but how to set a specific field on a specific value.

    For example on a page i want te use

    ACF/columns (set 2 columns)
    ACF/columns (set 3 columns)

    The field columns in the block columns need to get set in ‘data’ i think but I can’t find how.


    • NickDA

    • April 16, 2020 at 4:44 pm

    I had misunderstood your question… this is something I can use too… I will dedicate the next weekend to experiment with this, and I’ll post back here if I manage to find a solution. I’ve done 51 ACF blocks, bunch of Block Patterns (which are awesome and very easy to do), but never a template… time to dive into templates I guess now…

  • Hi, I’m not sure if this is what you are looking for but on my end it works great:

    add_action( 'init', 'slug_post_type_template' );
    function slug_post_type_template() {
    	$page_type_object = get_post_type_object( 'projects' );
    	$page_type_object->template = array(
    		array( 'acf/header', array() ),
    		array( 'acf/texts', array() ),	
    		array( 'acf/photos', array() ),	

    You can check the source on this page:

Viewing 5 posts - 1 through 5 (of 5 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.