Section
Overview
A full‑width content wrapper with robust styling and layout controls, designed to define major sections of a page.
- Block name:
method/section - Category:
method-layout-blocks - Supports:
align(wide, full) - Render type: Dynamic (PHP
render_callback) - Inner blocks: Yes — accepts any blocks
- Uses context:
postId,postType(for the featured-image background)
Usage
The Section block is the primary structural building block for full‑width page layouts. It outputs a <div> wrapper with layered background support (color, image, shade overlay), optional parallax and video backgrounds via Jarallax, and inner content that can optionally be constrained to the theme’s content width.
Insert a Section block, set it to Full Width alignment, and begin adding content inside it. Use the Inspector panel to configure spacing, background media, colors, dimensions, and responsive overrides.
When a Section is set to Full Width alignment, an Unconstrain Content toggle becomes available. When disabled (default), inner content respects WordPress’s constrained layout (is-layout-constrained with has-global-padding). When enabled, inner content stretches edge‑to‑edge.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
unconstrained | boolean | false | When true, disables constrained layout on full‑width sections |
bgVideo | string | — | Video URL for Jarallax background video (YouTube, Vimeo, or direct) |
useParallax | boolean | false | Enables Jarallax parallax scrolling on the background image |
textColor | string | — | Text color value |
linkColor | string | — | Link color value |
bgColor | string | — | Background color or gradient value |
bgGradient | string | — | Background gradient value |
bgShadeColor | string | — | Shade/overlay color value |
bgShadeGradient | string | — | Shade/overlay gradient value |
bgImg | object | { id: "" } | Background image object containing size variants with URLs |
bgMedia | string | "" | Background Media mode: empty for image / video, slideshow for a Vegas image slideshow |
images | array | [] | The slideshow images ({ id, url, … } per image), chosen with Select Slideshow Images |
useFeaturedImage | boolean | false | Use the current post’s featured image as the background, at the size in responsiveSettings.{breakpoint}.featuredImageSize |
responsiveSettings | object | (see below) | Per‑breakpoint settings for spacing, typography, dimensions, etc. |
responsiveSettings Structure
{
"base": { "enabled": true },
"mobile": { "enabled": false, "customBg": false },
"tablet": { "enabled": false, "customBg": false },
"wide": { "enabled": false, "customBg": false }
}
Each breakpoint can contain keys for padding, margin, fontSize, lineHeight, textAlign, height, minHeight, alignItems, border, borderRadius, bgImg, bgPosition, bgSize, bgRepeat, featuredImageSize, backdrop (a filter map for the shade overlay, see MethodBackdropControls) and boxShadow; zIndex and overflow at the base breakpoint, from Additional Options.
Control Sets
The Section block uses the following shared control components from lib/blocks/components:
| Component | Panel | Breakpoints | Notes |
|---|---|---|---|
MethodAlignmentControls | Alignment | base, mobile, tablet, wide | alignItems only; labeled “Content Vertical Alignment” |
MethodSpacingControls | Spacing | base, mobile, tablet, wide | Padding (all 4 sides) + Margin (all 4 sides) |
MethodDimensionControls | Dimensions | base, mobile, tablet, wide | height, minHeight, mhGroup |
MethodTypographyControls | Typography | base only | — |
MethodBorderControls | Border | base, mobile, tablet, wide | — |
MethodShadowControl | Shadow | base only | — |
MethodBackgroundControls | Background Media Options | base, mobile, tablet, wide | includeVideo and includeFeaturedImage on base; the panel also holds the Background Media selector (image / video or slideshow) and, in slideshow mode, hides the image controls |
MethodColorControls | Colors | global | textColor, linkColor, bgColor, bgShadeColor |
MethodResponsiveTabs | Responsive | mobile, tablet, wide | Wraps per‑breakpoint controls |
MethodAddtControls | Additional Options | base | zIndex, overflow |
MethodBackdropControls | Background Overlay Filters | base, mobile, tablet, wide | backdrop filters on .method-section-shade |
MethodStyleTag | — | — | Generates scoped <style> for editor preview |
Hooks
| Hook | Type | Arguments |
|---|---|---|
useResponsiveSetter | React hook | (attributes, setAttributes) — returns breakpoint‑aware setter function |
useMergeRefs | WP Compose hook | Merges blockProps.ref with Jarallax ref to preserve toolbar functionality |
Data & Dependencies
- Vegas:
inc/vegas/vegas-global.js(as a module) andvegas.min.cssare enqueued for the slideshow background; the render prints the slides asdata-vegas-slideson.method-section-bgimgand the slideshow fades between images on a 10-second interval. - Featured image: with
useFeaturedImagethe render readspostIdfrom block context and printsget_the_post_thumbnail()at the basefeaturedImageSizeas thejarallax-img, or resolves it per breakpoint throughmethod_get_block_responsive_styles(); the editor preview uses theFeaturedImagecomponent. - Jarallax: Both
jarallax.min.jsandjarallax-video.min.jsare enqueued on all pages viamethod_section_enqueue_assets. Jarallax is initialized in the editor via auseEffectwith retry logic (up to 20 attempts at 150ms intervals). - CSS Collector: Frontend CSS is generated by
method_get_block_responsive_styles()and collected viamethod_collect_css(), which consolidates per‑block<style>tags into a single output.
Frontend Rendering
The PHP render callback generates a unique ID (uniqid('method-')), builds a CSS selector map, passes it through Method’s responsive style system, and outputs:
<div class="method-section" id="method-{id}">
<div class="method-section-content {jarallax?}">
{jarallax-img?}
<div class="method-section-bgimg"> </div>
<div class="method-section-shade"> </div>
<div class="method-section-content-inner {constrained-classes?}">
{inner block content}
</div>
</div>
</div>
The link color is applied with a:not(.method-theme-button), so Theme Buttons inside a section keep their own colors; zIndex and overflow are emitted on the wrapper, and backdrop as backdrop-filter on .method-section-shade.
When useParallax or bgVideo is set, the background image is rendered as an <img class="jarallax-img"> element instead of a CSS background-image. The method-section-content div gains a jarallax class and data-jarallax / data-video-src attributes.
Filters
This block does not currently expose dedicated PHP filters. Customization is achieved through CSS targeting the generated #method-{id} selectors.
Changelog
| Version | Description |
|---|---|
| 2.0.0-alpha4 | Introduced (a09be88). |
| 2.0.0-beta5 | Additional Options: zIndex at the base breakpoint, emitted on the wrapper (1a17d90). |
| 2.0.0-beta6 | Use Featured Image background (useFeaturedImage, per-breakpoint featuredImageSize), postId / postType context, and the unused top-level bgSize and bgImgAlign attributes removed (09cc16b). |
| 2.0.0-beta8 | Image Slideshow backgrounds through Vegas (bgMedia, images), inside a reorganised Background Media Options panel that hides the image / video controls in slideshow mode (bd7d2f4). |
| 2.0.0-beta9 | overflow added to Additional Options and the wrapper’s CSS map (22945b6). |
| 2.0.0-beta17 | Link color selector narrowed to a:not(.method-theme-button) (60b9b07); useParallax and unconstrained corrected from bool to boolean (b4c7dcb); editor margins between consecutive sections zeroed (.method-section and theme.json) (8db7ce9); Inserter title prefixed, “Method Section” (c34e9bb). |
| 2.0.0-beta21 | Background Overlay Filters (MethodBackdropControls) on the shade overlay, base and responsive tabs (75910d2, 00817a3); .method-section-bgimg defaults to background-size: cover (75910d2). |
| 2.0.0-beta22 | A new Section starts with a placeholder paragraph (“Section content goes here…”) (4f34c8b); Retitled “Section (Method)” and given the method keyword (93e1fcf). |