Fork it, or download the latest release, and make it your own!
This is a demonstration of how you might create a custom Slider Block, which is a slider carousel UI. We're using SwiperJS (3rd-party dependency) for the slider JavaScript and CSS (mostly).
- Upload the
slider-block
folder to the plugins directory (typicallywp-content/plugins
) in your WordPress installation. - Activate the Slider Block plugin.
- Create a new post or page, and insert the Slider block.
- That's it.
- 🐛 FIX: missing memoization
- 👌 IMPROVE: Allowed Blocks = core/cover only
- Major refactor 😎:
- Remove need to have two custom blocks: Slider and Slide (
"parent": ['wpe/slider]
). This was just unnecessary and mildly confusing. We're ultimately utilisingInnerBlocks
anduseInnerBlocksProps()
to nest things. - Create
constants.js
to try and allow builders to drop in their own default blocks for slides. - Generally "cleaner" codebase.
- Remove need to have two custom blocks: Slider and Slide (
Initial release, which includes:
- Slider Block which uses SwiperJS (v11.0.5)
- Need help converting your block markup to PHP nested arrays or JS objects? Check out WPHTML Converter
- SwiperJS.