Support

Account

Home Forums Gutenberg 6.3 Block save to meta Reply To: 6.3 Block save to meta

  • I just did some experiments and I struggle a bit with how the workflow should be.

    Here’s how I did it to create block in my custom post type template.

    register_block_type(... path to folder containing block.json ...)

    – My block.json looks like this

    {
    	"name": "my-theme/template-quote",
    	"title": "Template Quote",
    	"category": "theme",
    	"icon": "format-quote",
    	"style": "wp-block-quote",
    	"acf": {
    		"usePostMeta": true,
    		"renderTemplate": "./template-quote.php"
    	}
    }

    – Adding a field group for this block.

    – When using Editor for block theme creating a custom template, the above block was not pickable until I removed the row "usePostMeta": true, so I added the block before adding the row again.

    – This was not enough to get the block editable when editing my custom post, because it was “outside” of my “Content” block, but it shows up in when using the Template Preview functionality.

    – I tried to add my custom post type to the ACF field group location rule, so it shows up for block or post type. I also changed presentation positiịn to “Side”, to get my ACF fields to show up in my custom post type sidebar in the block editor.

    Final thoughts / wishes / bugs(?)

    – To be able to add my block to the custom post type single template in the theme editor when usePostMeta: true, is important for my current dev workflow for building a block theme.

    – Editing my custom fields in the post editor sidebar will not update the block preview. Currently I need to reload the editor after update to see my changes in preview mode.

    – In Template Preview mode, I’m missing to be able to select my block to edit it – this would be awesome.