The Problem
Your editor.scss styles were targeting:
css.wp-block-custom-global-reach └── .global-reach
But your edit.js was rendering only:
html<section className="global-reach">
Two issues:
- Missing
useBlockProps()– WordPress wasn’t adding thewp-block-custom-global-reachclass - Missing wrapper div – There was no parent element for WordPress to attach the block class to
The Fix
Updated edit.js to:
- Import and use
useBlockProps() - Wrap the content with a
<div {...blockProps}>parent element
jsx// Before (broken)return ( <section className="global-reach"> ... </section>);// After (fixed)return ( <div {...blockProps}> <section className="global-reach"> ... </section> </div>);
Now the HTML structure matches your CSS:
div.wp-block-custom-global-reach ← Added by useBlockProps() └── section.global-reach └── (rest of content)
Refresh the WordPress block editor and your
global-reach
editor styles should now apply correctly! 🎉
WP开发教程 WordPress导师在线教程