Skip to content

code-mat/wp-hero-block

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WP Hero Block

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).


πŸ“¦ Installation

  1. 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
  2. Install dependencies and build assets:

    cd wp-hero-block
    npm install
    npm run build
  3. Activate the plugin in WordPress Admin β†’ Plugins.


⚑ Development

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

πŸ› οΈ Block Features

  • Background
    • Image (uses <img> with object-fit: cover for better LCP)
    • Vimeo embed via <iframe>
  • Overlay – optional, configurable opacity
  • Title (H1) – main headline
  • Scroll-to button – smooth scrolling to target section or next sibling

πŸ“‚ Project Structure

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

πŸ’‘ Example Usage

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

πŸ§‘ Author

Created by code-mat
Licensed under GPL-2.0-or-later

About

A custom Gutenberg block for creating a Hero section with image or video background.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published