A custom Gutenberg block for WordPress that renders a Hero section with:
- Background image or video
- H1 title
- Optional overlay
- Smooth scroll-to link
Built as a dynamic block with PHP render.php and bundled assets (@wordpress/scripts).
-
Clone or download this repository into your WordPress plugins folder:
cd wp-content/plugins git clone https://github.com/code-mat/wp-hero-block.git -
Install dependencies and build assets:
cd wp-hero-block npm install npm run build -
Activate the plugin in WordPress Admin β Plugins.
Start a development build with file watching:
npm run startBuild for production:
npm run buildCreate a plugin zip for distribution:
npm run plugin-zip- Background
- Image (uses
<img>withobject-fit: coverfor better LCP) - Vimeo embed via
<iframe>
- Image (uses
- Overlay β optional, configurable opacity
- Title (H1) β main headline
- Scroll-to button β smooth scrolling to target section or next sibling
wp-hero-block/
βββ build/ # Compiled JS/CSS after build
βββ src/ # Source files
β βββ block.json # Block metadata
β βββ edit.js # Block editor UI
β βββ style.scss # Frontend styles
β βββ editor.scss # Editor styles
β βββ view.js # Frontend JS (smooth scroll)
β βββ render.php # PHP render callback
β βββ index.js # Block registration
βββ wp-hero-block.php # Main plugin file
βββ README.md
After activating the plugin, insert the Hero Block in the WordPress block editor:
- Set a background image or video URL
- Add your title
- Enable/disable overlay
- Optionally add scroll-to target and link text
Created by code-mat
Licensed under GPL-2.0-or-later