This script fixes structural issues when using Splide sliders with Bricks Builder and Gutenbricks InnerBlocks.
- Gutenberg may insert multiple
<figure>elements (image blocks) inside a single Gutenbricks InnerBlock wrapper. - Bricks sometimes incorrectly applies
.splide__slideclasses to the wrapper instead of individual slides. - Splide requires the following structure:
<div class="splide__track">
<div class="splide__list">
<div class="splide__slide">
<figure><img src="..."></figure>
</div>
<div class="splide__slide">
<figure><img src="..."></figure>
</div>
</div>
</div>If the structure is wrong, Splide will not behave correctly (e.g., multiple images per slide, broken cloning, wrong loop behavior).
This script automatically wraps each Gutenberg <figure> in its own .splide__slide.
- Removes invalid
.splide__slideclasses from Bricks wrappers. - Wraps each Gutenberg image (
<figure>) in its own slide. - Cleans up empty wrappers.
- Fixes stray
<figure>elements directly under.splide__list. - Adds a small CSS fix to remove default WordPress figure margins inside slides.
-
In Bricks, add a Custom Attribute to your Gutenbricks InnerBlock container:
- Name:
data-splide-autowrap - Value:
1
- Name:
-
Add the JS file to your WordPress site:
- Recommended: enqueue it in your theme or child theme (in the footer).
- Alternatively: use a "Code Snippets" plugin.
-
Initialize your Splide sliders as usual.
<div class="brxe-gb-inner-blocks" data-splide-autowrap="1">
<!-- Gutenberg images will be inserted here -->
</div>After the script runs, your markup will be transformed to valid Splide slides.
- WordPress + Gutenberg (
core/imageblock). - Bricks Builder + Gutenbricks.
- Splide.js (any version).
- Works with multiple sliders on the same page.
- Only affects wrappers with the
data-splide-autowrapattribute.
License: MIT
Author: Your Name