Unlock Hidden Power: 6 Little-Known Ways to Master Custom Block Styles in WordPress
- PHP: To enqueue the necessary files
- JavaScript: To register the block style
- CSS: To style the block
The wp_enqueue_script()
function adds JavaScript files to a webpage. It’s not JavaScript itself, but rather a WordPress PHP function that’s often used in WordPress theme or plugin development. For this example, we can store the .js
file in the theme’s /js/
subdirectory and name it curate-core.js
.
The example code loads our custom curate-core.js
file after the necessary WordPress block editor scripts. It’s added to the bottom of the page for better performance and is hooked into enqueue_block_editor_assets
so it only loads in the editor.