On the front of the website I want the testimonials to be loaded randomly. Where can I adjust the query?
In the file itself I don’t see an “orderby” anywhere.
Hey Chris,
Thank you for the inquiry.
Are you using the slider format of the Testimonial element? If yes, then you can try this script in the functions.php file:
function ava_custom_script_randomize_testi()
{
?>
<script>
(function ($)
{
function g()
{
var $testimonialRow = $('.avia-testimonial-row');
var $testimonials = $testimonialRow.find('.avia-testimonial');
$testimonials.sort(function () {
return 0.5 - Math.random();
});
$testimonialRow.empty().append($testimonials);
}
$(document).ready(function ()
{
g();
});
})(jQuery);
</script>
<?php
}
add_action('wp_footer', 'ava_custom_script_randomize_testi');
Best regards,
Ismael
Hello Ismael,
Thanks for your response. Unfortunately it does not work on the slider that is used. In the testimonial slider we use the “Big testimonial slide”.
Attached is the link to the website and the required login details.
Kind regards.
Hi,
Thank you for the update.
We edited the functions.php file and adjusted the script a bit. Please make sure to purge the cache before checking the page.
Best regards,
Ismael
Works perfectly, thank you!