Support

Account

Home Forums Gutenberg Passing a variable to custom block from inside the editor.

Solving

Passing a variable to custom block from inside the editor.

  • Hello,

    I need to pass the custom post type slug as a variable to a custom block made with ACF. This needs to happen when the block is placed for the first time in the editor.

    What I want to achieve, is that the block detects the post type and then stores that value so it can be used when rendering the block in the frontend. It can not be done by css classes (that would be the obvious solution). I need to be able to output the CPT slug as a string in the single CPT page.

    Con anyone give me a hint on how to achieve this?

    Thank you!

  • I am also trying to pass a global select-type variable of the parent.block to all the inner.blocks. Is it possible?

  • Hi,
    it did work via the old
    acf_register_block_type
    function and global php variables.

    But with the new register_acf_blocks the global php variables seem not to work anymore.

    I think this is because the php files are not “connected” anymore.

    So f there is not wp trick something for this the only two solutions I can imagine are cookies or javascript.

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

You must be logged in to reply to this topic.