Interesting issue with ‘orderby’ => ‘rand’

This issue might be related to browser caching. Chrome could be caching the page, and when you navigate back to the homepage, it’s showing you the cached version instead of fetching a new version of the page with a different post order. To resolve this issue, you can try adding a cache-control header to your site to prevent browsers from caching the homepage.

You can achieve this by adding the following code to your active theme’s functions.php file:

function prevent_homepage_caching( $headers ) {
    if ( is_home() || is_front_page() ) {
        $headers['Cache-Control'] = 'no-cache, no-store, must-revalidate';
    return $headers;
add_filter( 'wp_headers', 'prevent_homepage_caching' );

This code will modify the headers sent by your server for the homepage, instructing browsers not to cache it. As a result, when users return to the homepage, they should see new posts regardless of which browser they’re using.

Please note that editing the functions.php file should be done with caution. Always back up your site and theme files before making any changes.

Additionally, keep in mind that preventing caching for your homepage might increase server load and decrease your site’s performance, especially if you have a high amount of traffic. It’s essential to balance the desired behavior with the performance implications to ensure an optimal user experience.

  • This reply was modified 2 hours, 45 minutes ago by Linards.

That works! Thank you very much for the snippet! And I appreciate the heads up on the server/site performance. I’m fairly confident that my website will never generate any traffic but I love doing it anyway 🙂


This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer