Latest Projects WordPress

Transforming a Single WordPress Block into a Block Variation with InnerBlocks

One minor victory in the latest updates to my RSVPMaker plugin was figuring out a block transform to turn a single block, RSVPMaker Upcoming, into a variation on the Query Loop block.

With this configured, the Transform To options displayed when you click on the calendar icon in the button bar include Query Loop — complete with a preview of what the transformed block will look like with my defaults applied.

The tricky part was turning a single block (rsvpmaker/upcoming) into a version of the Query Loop (core/query) with preset InnerBlocks for the Post Template (a container for the blocks representing the post title and other elements, in this case including the event date and time).

This related post explains what I was trying to achieve:

The official Transforms documentation covers a number of use cases, including a scenario where you are transforming one block that contains InnerBlocks to another — you take the InnerBlocks object passed in by the source and pass it in to the createBlock call for “Transform to” operation. In my case, I needed to create the blocks from scratch.