wordpress-blocks-boilerplate
wordpress-blocks-boilerplate copied to clipboard
WordPress blocks boilerplate to get started with Gutenberg development.
them.es WordPress Blocks
them.es WordPress Blocks is a WordPress "Gutenberg" blocks boilerplate which can be included in a theme.
What's included?
- Gutenberg blocks configuration tested in WordPress v5.8+
- The legacy boilerplate which is compatible with WordPress <5.8 can be found in the "v1" branch
- NPM configuration
- ESNext
- Support for a category where all custom blocks can be organized
- A simple "Hello world" block implementation is included
- Optional: Easily add more blocks
Setup
- Prerequisites: Node.js (NPM) needs to be installed on your system
- Download the source code of this repository to a new directory (e.g.
/blocks) in your WordPress theme - Add the following code snippet to
functions.phpin your theme (or reference it in your plugin's index.php file)
$theme_blocks = __DIR__ . '/blocks/index.php';
if ( is_readable( $theme_blocks ) ) {
require_once $theme_blocks;
}
- Open the
blocksdirectory in Terminal and install the required Node.js dependencies: $ npm install- A simple
Hello worldblock implementation is included to get you started. More examples can be found in the official Gutenberg examples repository - You can include additional blocks by duplicating
/src/##### - Run the
startscript: $ npm run start- Develop the block(s) by modifying
/src/#####/index.js- the official Gutenberg Handbook may help you learn how to build a custom block - When you're done run the
buildscript to create a minified version of your blocks: $ npm run build- Test the block(s) in the WordPress Editor
Technology
Copyright & License
Code and Documentation © them.es
Code released under GPLv2+