Show Random CMS Item Every Page Refresh?

I have some testimonials in CMS and I would like to display 1 testimonial item each time the page refreshes. It doesn’t work with Webflow’s Random/Shuffle Order display since what I read on this forum that there is like 12 hour refresh time. And it makes this option useless for me.

I saw some scripts on one of Pixelgeek’s Youtube videos (Showing a random featured CMS item in Webflow | Tutorial - YouTube). But I couldn’t get it to work.

Can someone help me, please?

My site:
(Please see the testimonial section just above the footer)

https://preview.webflow.com/preview/michelle-osbourne?utm_medium=preview_link&utm_source=designer&utm_content=michelle-osbourne&preview=93f09e925b572803c3ba304cf5227662&pageId=5fdeba870d2354047744a040&mode=preview

I think @PixelGeek’s tutorial is the way to go for this, what issue did you run into when you tried to use his method?

Since it requires the site to be published I can’t “test” it out on your project, but if you walk through the steps again from his video and publish the project I can double check the live site and Designer view to ensure you got everything set up correctly :+1:

Thank you for your reply!
I am no code expert. So I’d really appreciate your help. I tried some coding as I saw in the video. But it didn’t work. With my last modification to the code, the CMS content is not showing on the website.

Test site: https://michelle-osbourne.webflow.io/services
Read-Only Link: Same link as in my first post

Thank you!

Of course!

It looks like you need to change your styles in the <head> tag a bit:

<style>
  .testimonial-item {display:none}
  .testimonial-item.show {
    display: block;
  }
</style>

I’d also recommend not limiting the collection to a single item as the video shows initially. I believe Webflow only randomizes the list order when you republish, so it’s technically only able to add the .show class on a single item part of the time. While it’s not visible at all, it does sometimes render the correct combo class—just with incorrect syntax:

1 Like

I’ve changed the code as you suggested. And I’ve changed the number of displayed items to “2” (since I only 2 testimonials to show). Now it works correctly! (I hope this info helps those who checks this topic in the future)

The only downside is now in Webflow designer I see all the testimonials together.

Thank you so much! :slight_smile:

Is this still the only way to achieve this?

It’s not very convenient if you have a lot of quotes, or if you add/remove quotes, as you would have to change the code on every page it’s used

I saw this post

Which @thesergie suggests they will be looking at sorting this?

Can you please tell me what I’m doing wrong here?

https://preview.webflow.com/preview/mcube-design?utm_medium=preview_link&utm_source=designer&utm_content=mcube-design&preview=9f7e876d4550972ec9fede72259cd137&workflow=preview