If you have a dynamic gutenberg block, and in the PHP render_callback
, your code includes a custom query and loop, then it will break the editor.
This test plugin demonstrates the issue.
- Create a new page.
- Add the 'Demo Dynamic Post Block' block
- Add one or more image IDs. Comma separated (e.g.
12, 523
) - Save a draft.
- If you preview the page - this will work as expected. You will see the image titles and IDs.
- If you reload the page in the editor, the page will break with the following JS error:
Unhandled promise rejection TypeError: "r.content is undefined"
Notes
- this works fine if I roll back to v3.0.1. It is broken in versions v3.1.0 and newer.
- If you query for post type
post
instead of image, then the content of the editor is replaced with the content of the post queried in therender_callback
.