Streaming live at 10am (PST)

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: Services | Michelle Osbourne
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:

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: