Home Forums Gutenberg 6.3 Block save to meta


6.3 Block save to meta

  • Been waiting for years for this, but now I don’t seem to understand how to use it:
    ACF 6.3 Beta 1 (apparently) has the ability to save meta fields into the database from an ACF block.

    However, I have not been able to get it to work, and I’m now trying to understand what “This functionality would enable you to create a custom post type, with a locked block template, letting you replicate a classic editor-like experience where only your block exists to enter specific structured data. This data would then be stored in post meta and allow you to query it easily.” means. It does sound more restricting than what I was hoping for.

    Looking forward to some examples đŸ™‚

  • 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.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.