• Resolved CBphotography

    (@cbphotography)


    No matter what variation of the [strong] short code I use (custom or default), I can’t get the “Random” call to work to pull random testimonials to my page with the short code. Instead for example with a call for 3, I will always see the 1st, 2nd and third testimonials in order of when they originally were put into my system.

    Current short code…
    [strong class=”three-css-columns” more_post more_text=”read more…” length=”330″ count=”3″ category=”548″ random title thumbnail ]

    Any thoughts?

    Here is a link to my dev site where I am getting everything read before migrating over my domain. LINK (Testimonials at bottom of page)

    https://www.ads-software.com/plugins/strong-testimonials/

Viewing 8 replies - 1 through 8 (of 8 total)
  • ehoanshelt

    (@ehoanshelt)

    Hey!

    I’m with WP Engine and wanted to see if I could chime in and help here.

    In wp-admin, go to the WP Engine section of your dashboard and scroll all the way to the bottom. (This will be the page where you can purge cache)

    You will see a toggle for allowing the RAND() function in MySQL to properly execute. Here is a screenshot:

    https://take.ms/UeaGt

    That should allow your random ordering to work properly. ??

    Thanks!
    Eric

    Thread Starter CBphotography

    (@cbphotography)

    Thanks Eric. That is a big help. Love the support from WP Engine ??

    I see all the warnings about this feature in terms of it slowing things down. With a relatively small site, is that something I should worry about?

    ehoanshelt

    (@ehoanshelt)

    Hey!

    Small sites should be fine. ??

    As you post table grows (Testimonials het stored in the same table as posts, pages, etc) you may start seeing a performance hit. But as long as your site is small with a low amount of traffic, RAND() should be fine.

    Thanks!
    Eric

    Thread Starter CBphotography

    (@cbphotography)

    Whats “low”? ??

    Is there any solution to allow random testimonials with this plugin to work without having it affect the performance of my site. My testimonials shouldn’t reach more than a couple hundred and as far as web traffic, less than 100k a month.

    ehoanshelt

    (@ehoanshelt)

    Without getting to much into numbers because a lot of factors are in play when it comes to scalability of the site. If it is a couple hundred a month, I feel comfortable saying your site should be fine.

    I would take a webpagetest.org snapshot of the site performance now before turning on Rand() and then again in a few days to see if you see a huge spike in performance.

    Is there any solution to allow random testimonials with this plugin to work without having it affect the performance of my site.

    NERD TALK AHEAD:
    I’ll let the developer answer that question but to offer a suggestion to him/her/team, if the order by rand() is an essential feature of the plugin, remove any use of the rand() function in MySQL and let PHP handle it. Pull all the testimonials from the database and output random one via PHP from the MySQL response. MySQL Indexes that are installed by default In WordPress should make sure that MySQL outputs the information quickly while PHP can randomize the testimonials in a more productive way.

    Now, the plugin developer may not have intentionally used the RAND() function, rather the orderby => ‘rand’ argument in WP_QUERY. This will cause the function to be used in MySQL.
    END NERD TALK

    I hope this helps!

    Thread Starter CBphotography

    (@cbphotography)

    Very helpful. Thanks again!

    I will wait to hear from the developer before marking this as resolved:)

    Plugin Contributor Chris Dillon

    (@cdillon27)

    Thanks for the advice and for stepping in Eric, that would have taken me days to figure out.

    I am indeed using orderby => rand and I am very curious to know at what point it affects performance.

    But the PHP technique is sound and I will change the plugin soon.

    Plugin Contributor Chris Dillon

    (@cdillon27)

    Random order has been moved from SQL to PHP in version 1.16. You can disable MySQL RAND() in your WP Engine settings.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘"Random" Call Not Working’ is closed to new replies.