Building Blocks without Javascript? Yes, you can.

Not everyone is able or willing to build blocks in JavaScript just yet. I found three plugins who help with that.: Block Lab, ACF (Advanced Custom Fields) and Lazy Blocks.

Creating a Team member block was the simple use case for my test. I made notes, screenshots and videos along the way. Last week, with the generous help from Sarah Gooding, the write-up was published on the WPTavern.

More Tools for Block Building in PHP

With the wider reach of the article, others chimed in and shared their discoveries and opinions as well. Here are two:

PHP vs. Twig, I’ve used Twig within ACF blocks, often in conjunction with the Timber plugin. The PHP file that is used to display the block just needs to gather the data for the Twig template and then render it. It adds a bit more complexity (and two files, a PHP and a Twig, per block) but as Twig is pretty easy for folx to mess with, it’s been a good solution for me.

David Dashifen Kees on the WPTavern

(…) a viable PHP-only option for creating a block is Carbon Fields.

A quick comparison:

  • Carbon Fields has no UI within the admin area, which means that the creation of a block is only accomplished via code in a plugin or theme.
  • The creation of the block itself is very easy and follows the same pattern that the rest of the library uses to create meta boxes, widgets, theme options panels, etc.

wrote Steve Ryan in his comment


Featured image: Photo by Matthew T Rader on Unsplash