This "Copyright Date" block utilizes static and dynamic rendering, block supports, custom attributes, and a custom Settings panel.
This example is directly adapted from the resulting code got when following the quick steps explained at Block Editor Handbook / Getting Started / Quick Start Guide
npx @wordpress/create-block copyright-date-block --template @wordpress/create-block-tutorial-template
Example | Description | Tags | Download .zip | Live Demo |
---|---|---|---|---|
Copyright Date Block | Example of a block that combines both static and dynamic rendering to display copyright information. | dynamic-rendering static-rendering create-block featured |
📦 |
Some highlights about the code:
- It defines at
render.php
the server-side rendering of the block which will generate the markup to be returned to the browser at request time - It also defines the markup representation of the block at
save.js
which will be stored in the DB. This representation of the block in the DB will be returned to the browser in case the plugin is uninstalled or disabled - It builds custom settings controls for the block in the Sidebar Panel with
InspectorControls
- It uses some UI components such as
PanelBody
,TextControl
andToggleControl
from '@wordpress/components';
- Block Editor Handbook / Getting Started / Quick Start Guide
- '@wordpress/components'
@wordpress/block-editor
Note Check the Start Guide for local development with the examples