• Hello,

    I didn’t find any way if it’s possible to update the block attributes from the front-end (via PHP or Ajax).

    The block is a custom dynamic block that has some API data rendered in, I’d like to cache the result of API into the block attributes when it becomes available (hence, I can’t do this from the editor when creating the block).

    For now, the only possible solution I see is to replace the block HTML comment string with a new string and save the new post content via AJAX. Is there any native function to save the new attribute to the block when it’s rendered?

    Thank you,
    Oksana

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Oksana, you said that it was a custom dynamic block, did you mean that it was build using the technique described in the Creating Dynamic Blocks documentation?

    If not, then it sounds like that documentation is what you’re looking for.

    The reason I ask is that, when creating dynamic blocks, there isn’t any data that gets saved in post_content. Instead, the front end is rendered by a PHP function, while the back end is rendered by JavaScript.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Update block attributes from front-end’ is closed to new replies.