WordPress has hundreds of carousel plugins. Most load 200KB+ of JavaScript, add admin bloat, and slow down your site. If all you need is a clean carousel slider, that's overkill.
Here's a lighter approach: add a single script tag and use HTML attributes. No plugin to install, no settings page to configure, no database queries on every page load. The carousel runs entirely from a CDN - your WordPress install stays clean.
This guide uses the Swiper carousel from OneType Transforms - a premium component that works on any site, including WordPress. For the full overview of features and effects, see the main carousel slider guide.
How to add a carousel slider to WordPress
Step 1: Add the script tag
The Swiper carousel is a premium transform. Sign up for a Pro or Agency plan at transforms.onetype.ai/pricing, then grab your script tag from the Get Started page.
The easiest way to add the script site-wide is with the free WPCode plugin (2M+ installs):
- Go to Plugins > Add New, search "WPCode", install and activate
- Go to Code Snippets > Header & Footer
- Paste your script tag in the Header section
- Click Save Changes
<script src="https://cdn.transforms.onetype.ai/bundle/{YOUR-TOKEN}.js"></script>This loads the script on every page of your WordPress site. One-time setup.
Developer alternative: If you prefer code over plugins, add this to your child theme's functions.php:
function add_onetype_transforms() {
wp_enqueue_script(
'onetype-transforms',
'https://cdn.transforms.onetype.ai/bundle/{YOUR-TOKEN}.js',
array(),
null,
false
);
}
add_action('wp_enqueue_scripts', 'add_onetype_transforms');Step 2: Add the carousel HTML
In the Gutenberg editor, add a Custom HTML block where you want the carousel:
- Click the + button to add a new block
- Search for Custom HTML
- Paste the carousel HTML
<div ot="swiper" ot-navigation="true" ot-pagination="bullets">
<div><img src="https://your-site.com/image-1.jpg" alt="Slide 1"></div>
<div><img src="https://your-site.com/image-2.jpg" alt="Slide 2"></div>
<div><img src="https://your-site.com/image-3.jpg" alt="Slide 3"></div>
</div>Save and preview the page. The carousel activates on the live site - you won't see it in the Gutenberg editor preview.
WordPress.com vs WordPress.org
If you're on self-hosted WordPress.org, everything above works out of the box. Install WPCode, add the script, done.
If you're on WordPress.com, it depends on your plan:
- Business or Commerce plan ($25+/mo) - full access. Install WPCode, same as self-hosted.
- Free, Personal, or Premium plan - can't install plugins. Add both the script tag and carousel HTML together in a Custom HTML block on each page.
Using the carousel with page builders
If you use Elementor, Divi, or Beaver Builder instead of Gutenberg, the process is the same idea - just different UI:
- Elementor - use the HTML widget to add the carousel markup. Elementor Pro users can also use Elementor > Custom Code instead of WPCode for the script tag.
- Divi - use a Code Module for the carousel HTML. Add the script in Divi > Theme Options > Integration > Head.
- Beaver Builder - use an HTML Module. Add the script via WPCode or the BB Theme's Head Code setting.
Carousel examples for WordPress
Image gallery with autoplay:
<div ot="swiper" ot-autoplay="true" ot-autoplay-delay="4000" ot-loop="true" ot-pagination="bullets">
<div><img src="gallery-1.jpg" alt="Photo 1"></div>
<div><img src="gallery-2.jpg" alt="Photo 2"></div>
<div><img src="gallery-3.jpg" alt="Photo 3"></div>
</div>Multi-card product showcase:
<div ot="swiper" ot-slides-per-view="3" ot-space-between="20" ot-navigation="true">
<div class="product-card">Product 1</div>
<div class="product-card">Product 2</div>
<div class="product-card">Product 3</div>
<div class="product-card">Product 4</div>
</div>Testimonial slider with fade effect:
<div ot="swiper" ot-effect="fade" ot-autoplay="true" ot-autoplay-pause="true" ot-pagination="bullets">
<div>"Great product, saved us hours." - Sarah K.</div>
<div>"Simple to set up, works perfectly." - Mike R.</div>
<div>"Best slider solution we've tried." - Team at Acme</div>
</div>Why not use a WordPress slider plugin?
Slider plugins like Revolution Slider, Smart Slider, or MetaSlider are full-featured tools. They're great if you need a visual editor with drag-and-drop slide building, animation timelines, and template libraries. But they come with tradeoffs:
- Heavy JavaScript and CSS (200-500KB+ per page)
- Admin dashboard overhead and database queries
- Plugin conflicts with themes and other plugins
- Locked to WordPress - can't reuse on other platforms
The OneType approach loads only what you use from a CDN. No admin panel, no database, no plugin updates to manage. And the same script tag works if you move to Webflow, Shopify, or any other platform later.
Troubleshooting
Carousel doesn't show up: Make sure you're viewing the published page, not the Gutenberg editor preview. Custom HTML blocks with external scripts only run on the live site.
Script tag gets stripped: WordPress strips <script> tags from content for users without the unfiltered_html capability. Make sure you're logged in as an Administrator. On multisite, only Super Admins can add scripts in content.
Caching issues: If you use a caching plugin (WP Rocket, LiteSpeed Cache, W3 Total Cache), clear the cache after adding the script tag. Cached pages may not include the new script.
For the full list of carousel options, effects, and advanced configuration, see the complete carousel slider guide. Browse all transforms at transforms.onetype.ai.






