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 start
Build for production:
npm run build
Create a plugin zip for distribution:
npm run plugin-zip
- Background
- Image (uses
<img>
withobject-fit: cover
for 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