{"id":2274,"date":"2026-10-20T08:29:35","date_gmt":"2026-10-20T07:29:35","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/random-sort-same-order\/"},"modified":"2026-10-20T08:41:01","modified_gmt":"2026-10-20T07:41:01","slug":"random-sort-same-order","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/how-tos\/random-sort-same-order\/","title":{"rendered":"Why random sort shows the same order every time in GeoDirectory"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Random sorting in GeoDirectory is random per day, so reloading the page shows the same order. GeoDirectory seeds the random order with a value that it keeps for 24 hours. Without that, page 2 of the results could repeat listings from page 1 or skip others, because every page would be shuffled again.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This applies to random sorting on the search and category pages and to <code>sort_by=&quot;random&quot;<\/code> on GD &gt; Listings, for example:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-markup\">&#091;gd_listings post_type=&quot;gd_place&quot; post_limit=&quot;12&quot; sort_by=&quot;random&quot;&#093;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Change the order more often<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The seed passes through the <code>geodir_rand_seed<\/code> filter. This snippet gives a new order every hour. Add it with the <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/useful-plugins\/code-snippets-plugin\/\">Code Snippets plugin<\/a> or your child theme&#8217;s functions.php.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">add_filter( &#039;geodir_rand_seed&#039;, &#039;my_gd_hourly_rand_seed&#039; );\nfunction my_gd_hourly_rand_seed( $seed ) {\n\treturn (int) floor( time() \/ HOUR_IN_SECONDS );\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can return a new number on every page load, for example with <code>wp_rand()<\/code>, but then paging is no longer reliable. That is fine for a single block of featured listings with no paging.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Still seeing the same listings?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A page cache stores the whole page, including the order of the listings, until the cache is cleared. If you use a caching plugin or a host cache, the order only changes when the cache refreshes. You can exclude the page from the cache if the order matters more than speed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There is more on this in <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/code-snippets\/change-geodirectory-random-sorting\/\">Change GeoDirectory random sorting<\/a>. To add random as a sort option for visitors, see <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/core-features\/changing-or-adding-new-sorting-options\/\">Changing or adding new sorting options<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Random sorting in GeoDirectory is random per day, so reloading the page shows the same order. GeoDirectory seeds the random order with a value that it keeps for 24 hours. Without that, page 2 of the results could repeat listings from page 1 or skip others, because every page would be shuffled again. This applies [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[211,432],"class_list":["post-2274","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-tips-tricks-more","gd_placecategory-how-tos"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/types\/gd_place"}],"author":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/comments?post=2274"}],"version-history":[{"count":2,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2274\/revisions"}],"predecessor-version":[{"id":2719,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2274\/revisions\/2719"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=2274"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=2274"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=2274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}