Devteam Custom Blocks
Templating structure for the creation of custom Gutenberg Blocks (procedural PHP version).
by Matt Bedford | Ulisse · github.com/mattbedford/acf-blocks
★ 1stars
0forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/mattbedford/acf-blocks/archive/refs/heads/main.zipDevteam Custom Blocks
A utility plug-in to provide scaffolding for custom Gutenberg blocks.
Basic usage
- Clone this repo
- Spin up a new WP instance
- Install and activate Advanced Custom Fields Pro
- Inside ACF, import the
acf-export.jsonconfig file from this folder - Install and activate this plugin
- Open a page and add a block - you will find two custom blocks already made:
- Team Member Block
- Test Block
The blocks are both very, very rudimentary. Sorry. They're just an example.
Build your own
- Duplicate the
test-blockfolder from this plugin. - Inside it has the 3 critical files you need for a new block: the
block.json,style.cssandtemplate.php. - The plugin looks for any
block.jsonfiles and registers the block automatically. Your job is to edit the block.json and the template.php files only - Look inside the json: it's pretty intuitive. You'll need to update the name of the block, its icon and, once you feel confident, also the list of supports.
- If you'd like to add custom fields to your block, go to the ACF settings and add a field group - in the location rules, set to "Show this field group if
block is equal to [name-of-your-block]" - Update your
template.phpto take advantage of your new ACF fields. - Add your styles to the css file inside your new block folder and you're set.
NB: If you change a block's code (especially the block.json) after adding it to a page, you may need to remove the block element and add it again.
Check here for more info on using ACF blocks: https://www.advancedcustomfields.com/resources/acf-blocks-key-concepts/ And with this, you now never need to use shortcodes again! :)