With Gutenberg on the horizon for WordPress, it is a good idea to start providing some basic customization skills in preparation for the future. In this third of three webinars, we will build custom Gutenberg blocks that extend the prior two sessions and add in the ability for settings panels and custom stylings.
Webinar Originally Broadcast: September 23, 2023
Additional Downloads: PDF Handout
Audio Download (Podcast File) -> Download MP3
I have solved the issue that was experienced at the end of the webinar. There were TWO problems with my code.
The first issue could be found within the save function of the registerBlockType while I was setting the variables. What was written in the code (incorrectly) was this:
var content = props.attributes.alignment; var alignment = props.attributes.alignment;
What should have been written was:
var content = props.attributes.content; var alignment = props.attributes.alignment;
Notice how I was saving the attribute alignment to BOTH variables.
The second issue was the most important part, and the reason why the block was failing to “initiate”.
Except by doing that, I wasn’t actually “running” the instance of the block. What needed to occur on that last line was as follows:
(Such fun live coding can be) :)