Displaying a random testimonial on your Webflow page without using the Random/Shuffle Order display can be achieved through a custom script. Here's how you can implement it step-by-step:
1. Prepare Your Testimonials
- Ensure you have a collection of testimonials with individual testimonial items.
- Each testimonial should have a unique identifier if possible, like a specific class or data attribute.
2. Add Custom Code to Your Page
- Go to Project Settings in Webflow and then select the “Custom Code” tab.
- Use the “Inside <body> tag” section to paste your custom script.
- The following inline script is a basic example to randomize visible testimonials on page load:
```javascript
<script>
var testimonials = document.querySelectorAll('.testimonial-class'); // Adjust the class selector
var randomIndex = Math.floor(Math.random() * testimonials.length);
testimonials.forEach(function(testimonial, index) {
testimonial.style.display = (index === randomIndex) ? 'block' : 'none';
});
</script>
```
- Adjust the class selector
.testimonial-class to match your testimonial elements. - This script randomly selects one testimonial and sets its display property to 'block' while others are set to 'none'.
3. Publish Your Site
- Save your changes in the Project Settings.
- Publish your Webflow site to test the random testimonial display on page refresh.
4. Troubleshooting
- Ensure your testimonials have the correct class or identifier used in the script.
- Check for any JavaScript errors in the browser console that might indicate issues with the script.
Summary
To display a random testimonial each time your page refreshes in Webflow, use a custom script that selects and displays a random testimonial while hiding the others. Ensure the script matches the targeted elements and is placed correctly in the custom code settings of your project.