WordPress block settings: I’ve found them

I was hunting down documentation for WordPress (WP) block markup all over the internet, but I didn’t find anything that was particularly helpful. The advice seemed to be: create it in the block editor and see what WP produces. T’riffic.

Since then, I’ve been trying to work out how to create blocks for use in my Panda-Puss theme that I’m developing.

WordPress block creation in themes

I looked up the documentation on block creation; it isn’t helpful. There’s a snippet of code here and a snippet of code there, but the surrounding text doesn’t tell you which bits to change or where the code should go. The other thing I noticed was that every mention of writing your own blocks seems to go in plugins.

I looked in WP’s core code (in wp-includes/blocks) to see what the block code looked like there. I discovered that each block comprises block.json, two CSS files, style.css and editor.css (along with a load of corresponding RTL CSS files, minimised versions of all CSS files), and optional JavaScript and/or PHP files. It turns out that the tag markup in the HTML files is a subset of the “settings” key in the block’s JSON file. This is what I’ve been looking for all this time! There’s no explanation of what each setting does, so I’ll have to make educated guesses and do some experimenting.

I’m not sure whether to use it to complete my WP markup reference or to scrap the reference and just look everything up in the block files. Both are tedious, but once the former is done, it’s done, and I don’t have to search through a load of files for something. I’ll maybe do the former.

Add a comment?

This site uses Akismet to reduce spam. Learn how your comment data is processed.