Splide Carousel Block

外掛說明

The Splide Carousel block introduces the capability to create carousels/sliders within the block editor. Each carousel may contain an infinite number of slides, with each slides containing their own inner blocks.

Use the Splide Carousel block to create image carousels, testimonial rotators, and more in Gutenberg!

View Demo

Options

  • Arrows Navigation
  • Dots Pagination
  • Autoplay
  • Slide and Fade Transitions
  • Infinite Loop
  • API to control the carousel using JavaScript
  • Fixed Slide Width / Height
  • Variable Slide Width / Height
  • Number of Slides Per Page
  • Slide Spacing
  • Video Support
  • Auto Scroll
  • Hash Navigation
  • Lazyload
  • FSE (Full Site Editing) Compatible
  • Fully Accessible
  • RTL Support
  • Responsive
  • No Google Lighthouse Issues
  • Lightweight
  • …and more!

Attribution

The Splide Carousel block uses the Splide library.

螢幕擷圖

  • Block editor view
  • Block editor view
  • Front end view
  • Front end view
  • Block controls

適用於區塊編輯器

這個外掛提供 2 個可供 Gutenberg/區塊編輯器使用的區塊。

  • Splide Carousel
  • Splide Carousel Item

安裝方式

  1. Upload the plugin files to the /wp-content/plugins/splide-carousel directory, or install the plugin through the WordPress plugins screen directly.
  2. Activate the plugin through the ‘Plugins’ screen in WordPress

常見問題集

Are there additional options I can use?

Yes, under the Splide Carousel block Advanced Settings, you can provide a valid JSON string containing additional options located here.

e.g.: {"focus":"center","trimSpace":false}

Can I set default carousel options globally?

Yes, we need to listen to a JavaScript event that is fired when the carousel is ready, and then add the defaults.

document.addEventListener( 'splideReady', function( e ) {
    e.detail.defaults = {
        arrowPath: 'M30.2 19.4L11 .2c-.3-.3-.9-.3-1.2 0-.3.3-.3.8 0 1.2L28.4 20 9.8 38.6c-.3.3-.3.9 0 1.2.3.3.9.3 1.2 0l19.2-19.2c.3-.3.3-.9 0-1.2z',
        perPage: 3
    };
} );

Can I control the carousel using JavaScript / API?

Yes, each carousel is given a unique ID by default, or you can provide your own using the HTML Anchor field under the block Advanced Settings.

Each block exposes a global variable that follows this convention: {ID}Carousel. For example, if your carousel ID is testimonials, the global variable will be testimonialsCarousel.

Using this global variable, you can control the carousel programatically using the Splide API.

Example to navigate to the third slide:

testimonialsCarousel.Components.Controller.go(2);

使用者評論

2025 年 5 月 11 日
This is fantastic, very low on resources. Can you please add blocks for previous and next buttons so that we can place them according to our needs? Again, thank you for this free treat.
2025 年 2 月 27 日
I pretty much always use splide in my non-WordPress projects, so great to see it as a block. So far no problems with it, and all the important options are there. I just wish there was a query-loop block for this, ( I would pay for this ) Keep it up!
2025 年 2 月 5 日
I have tried multiple carousel plugins and end up finding out there’s a splide js plugin. Really useful for an experienced developer to customise their carousels and is enough for those that have no experience to use as well!
閱讀全部 11 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈Splide Carousel Block〉的開發相關工作。

參與者

〈Splide Carousel Block〉外掛目前已有 1 個本地化語言版本。 感謝全部譯者為這個外掛做出的貢獻。

將〈Splide Carousel Block〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

1.7.1

  • Enhancement – Compatibility with WordPress 6.9
  • Fix – responsive breakpoint changes causing unexpected or invalid content

1.7.0

  • Enhancement – Update Add New Slide button to work with native Inserter to support cloudcatch/splide-carousel-item variations / defaults

1.6.0

  • Enhancement – Bump block apiVersion to 3
  • Chore – Update dependencies and WordPress compatibility to 6.8

1.5.0

  • Enhancement – Compatibility with WordPress 6.7

1.4.7

  • Fix – Slides not visible in RTL direction mode

1.4.6

  • Fix – Speed setting change causing unexpected / invalid content error

1.4.5

  • POTENTIAL BREAKING CHANGE:
    Now using the CSS class .wp-block-splide-carousel to encapsulate the carousel and its components. If you have any custom styles applied to the carousel or its components, it’s recommended to test this update in a staging environment before updating in production.

1.4.4

  • Fix – Carousel JavaScript variable name duplicating “Carousel” in the name

1.4.3

  • Fix – HTML Anchor not applying to carousel

1.4.2

  • Fix – Prevent autoplay and auto scroll in block editor

1.4.1

  • Docs – Update tested up to

1.4.0

  • Enhancement – Improved editor UX
  • Enhancement – Added ability to make entire slide clickable link

1.3.0

  • Enhancement – Added Grid extension
  • Enhancement – Added autoplay play/pause buttons

1.2.0

  • Enhancement – Added Inspector Controls to avoid having to use JSON
  • Enhancement – Exposed global variable to programatically control the carousel using the Splide API

1.1.0

  • Enhancement – Ability to add photos in bulk when new block is created and when block has no slides

1.0.0

  • Initial release