Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1466033

    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.

    #1466080

    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

    #1466102

    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.

    #1466121

    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

    #1466130

    Works perfectly, thank you!

    #1466170

    Hi,

    You’re welcome! Please let us know if you have more questions about the theme.

    Have a nice day.

    Best regards,
    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Randomize testimonials’ is closed to new replies.