How to Create Testimonial Slider in Gutenberg (without Plugin)

Tired of the same old static testimonials gathering dust on your website? Would you like to add some compelling social proof to your website so that your visitors are genuinely captivated? Look no further!

This tutorial unlocks the secrets of crafting a fascinating testimonial slider within the WordPress Gutenberg editor without relying on a single plugin.

Forget fumbling with third-party installations and bloated interfaces. We’ll harness the power of native Gutenberg blocks and custom code to sculpt a slider that showcases your glowing reviews in stunning style.

Example of Testimonial Slider in Gutenberg.

Steps to Create Testimonial Slider in Gutenberg (without Plugin)

Step 1: Add the Code Snippet to the functions.php File

First, we will add the PHP snippet to the functions.php file.

On your WordPress dashboard, go to Appearance > Theme File Editor. You can find Theme File Editor under the Tools menu if you’re using a block theme.

Once you enter the Theme File Editor page, select the functions.php file. Afterward, paste the PHP snippet below at the end of the function file content. Next, update the theme file by clicking the Update File button.

function ti_custom_javascript() {
    ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
    <script>
$(document).ready(function() {

$('.next-btn').click(function() {
  var currentSlide = $('.wpb-slide.wpb-active-slide');
  var currentSlideIndex = $('.wpb-slide.wpb-active-slide').index();
  var nextSlideIndex = currentSlideIndex + 1;
  var nextSlide = $('.wpb-slide').eq(nextSlideIndex);
  currentSlide.fadeOut("fast");
  currentSlide.removeClass('wpb-active-slide');
  if (nextSlideIndex == ($('.wpb-slide:last').index() + 1)) {
    $('.wpb-slide').eq(0).fadeIn("fast");
    $('.wpb-slide').eq(0).addClass('wpb-active-slide');
  } else {
    nextSlide.fadeIn("fast");
    nextSlide.addClass('wpb-active-slide');
  }
});

$('.prev-btn').click(function() {
  var currentSlide = $('.wpb-slide.wpb-active-slide');
  var currentSlideIndex = $('.wpb-slide.wpb-active-slide').index();
  var prevSlideIndex = currentSlideIndex - 1;
  var prevSlide = $('.wpb-slide').eq(prevSlideIndex);

  currentSlide.fadeOut("fast");
  currentSlide.removeClass('wpb-active-slide');
  prevSlide.fadeIn("fast");
  prevSlide.addClass('wpb-active-slide');
});

});
    </script>
    <?php
    }
    add_action('wp_head', 'ti_custom_javascript');

Note: If you are afraid of breaking your site after adding the new function to the functions.php file, you can create a child theme or custom plugin. Read here to learn more.

Adding custom snippet to functions.php file.

Step 2: Add the Custom CSS

Next, we will add the additional CSS to your WordPress site.

On your WordPress dashboard, go to Appearance -> Customizer -> Additional CSS. Copy the CSS snippet below and paste it into the input field. If you use a block theme, you may need to enable the theme customizer first.

Here is the CSS snippet you can use:

.wpb-slide{
 display: none !important;
}
.wpb-active-slide {
  display: block !important;
}
.wpb-slide h3 {
    display: inline;
}
.wp-container-17.wp-block-buttons.eplus-wrapper {
    margin-top: -35px;
}
.wpb-slide .wp-block-column:last-child img {
    height: 475px;
    width: 475px;
    object-fit: cover;
}

.slide{
    display: none !important;
   }
   .active-slide {
     display: block !important;
   }
   .slide h3 {
       display: inline;
   }
   .wp-container-17.wp-block-buttons.eplus-wrapper {
       margin: 0 auto;
   }
   .slide .wp-block-column:last-child img {
       height: 700px;
       width: 700px;
       object-fit: cover;
   }

Once you finish adding the CSS snippet, apply it by clicking the PUBLISH button.

Adding custom CSS in theme customizer.

Step 3: Create the Testimonials Slider

Once you add the custom PHP and CSS code, now it’s time to create the content (testimonial slider). We will start everything from scratch, so create a new post type (page/post).

1st Slide

  • Add the Group Blocks

First, add the Group block to the content area. Next, set the size of the block as you desire. For this example, we set it to 700 px for both sides (content and wide).

Create the first slid of the testimonial slider.

Next, please add another Group block inside the Group block you’ve just added. Afterward, assign the CSS classes wpb-slide and wpb-active-slide to the group.

  • Add the Columns Block

Inside the wpb-slide wpb-active-slide group, add the Columns block with a single column.

  • Add the Image Block

Here, we will add an Image block to make it a photo of the person who gave the testimonial. You can upload an image file by picking one from your media library or adding one with a URL.

Once you add an image to the block, style up your image as you prefer. For this example, we set the align to Center, Rounded style, and 110px for both the width and height of the image.

  • Add the Heading Blocks

Next, we will add two Heading blocks; the first block will be filled with the name of the testimonial giver, and the second will contain their occupation.

  • Add the Slider Buttons

First, add the Columns block with two columns and the Button block inside each column. We will use the buttons as a trigger to slide the testimonial. The left side is for the previous slide, and the right side is for the next slide.

Next, we’re going to add the icon to the buttons. There are many ways to do that. For this example, we will simply go to the Copy Glyphs, select your liking icon, and paste it to the buttons.

Next, add the CSS class for each button, prev-btn for the previous button and next-btn for the next button.

  • Add the Testimonial Text

Add the Paragraph block, then write the testimonial text accordingly.

  • Add the Inline Star Rating

To add an inline star rating, actually we have separate post covering how to add inline star rating in WordPress, you may need to read that post if you want to add the star rating to your testimonial slider.

2nd Slide

Now, it’s time to create the second testimonial slide.

  • Duplicate the Group Block and Revise the CSS Class

Duplicate the Group with the classes wpb-slide wpb-active-slide. Once you duplicate the group, you first need to revise the CSS classes of the Group block to wpb-slide.

Creating the second slide of the testimonial slider.
  • Modifying the Slider Content

Once you duplicate the group block and revise the CSS class, you can update the second slide by replacing the image and text.

That’s it. Repeat this step for the third slide and your subsequent testimonial slide. To see the result, you can preview your testimonial slider page by clicking the Preview button. Don’t forget to save or publish your page if you want to.

Final result of the testimonial slider.

The Button Line

With a little bit of custom code (PHP and CSS) and the power of native Gutenberg blocks, you can easily showcase your glowing reviews in an eye-catching and visually appealing manner. Your visitors will now experience a captivating journey through authentic social proof, making your website more compelling and trustworthy.

Embrace the simplicity of this approach and let your testimonials shine with a seamless and plugin-free slider. This article demonstrates how easy it is to create the testimonial sider in Gutenberg was the one without the help of any plugins. Say goodbye to the hassle of third-party installations and bulky interfaces.

This page may contain affiliate links, which help support our project.Β Read our affiliate disclosure.
Picture of Akbar Padma

Akbar Padma

Akbar is a WordPress expert and a writer staff at WPPagebuilders. He mainly writes about Gutenberg, Elementor, Divi, and other WordPress page builders.
Want to start a profitable blog with WordPress?Β OF COURSE!

3 thoughts on “How to Create Testimonial Slider in Gutenberg (without Plugin)”

  1. This is working great. I have a question tho..
    Once I included all the styles and published it, I can’t see the slides in the editor (just the first one) kind of simulating the frontend but not quite (we can’t navigate to the other slides to edit).
    Any advice?

    Reply
    • Hi Cynthia,
      Thank you for your question and for sharing your experience!
      It sounds like you’re encountering an issue with viewing multiple slides in the editor.
      If the issue started after adding the styles (custom CSS), you can temporarily adjust the visibility. Change the property values of display: none; to display: block; temporarily.

      Thank you

      Reply
      • Thank you for your reply! I changed that property on the editor only to allow the end-user to see it all even if the display is not 100% the same as the frontend πŸ™‚

        Is there a way we could add pagination between the arrows? That would be absolutely perfect!

        Reply

Leave a Comment

Hey πŸ‘‹πŸ»
Got WordPress knowledge?
Why not turning it into profit? Click the button below to learn how.

Your popup content goes here

50%

Where should we send the template?

After entering your email address, you will be added to our newsletter subscribers. You can unsubscribe anytime.

Want to Build Passive Income Like the One on the Screenshot Below?

Click the button on the right side to learn how πŸ‘‰πŸ»
5 easy steps to turn your WordPress knowledge into monthly recurring revenue.

Click the above button to close the popup.