From 3b97459b1514035e2743a61bd908e9f1b7a7ed4f Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Fri, 13 Dec 2019 15:41:00 -0500 Subject: [PATCH] Pledge List: Change list order hourly (#132) Using a seed for the RAND function, based on the date & time, will randomize the list every hour, while keeping the order consistent across any pagination. This also removes the increase to posts_per_page, since pagination is functional again. Fixes #70 --- plugins/wporg-5ftf/includes/pledge.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/wporg-5ftf/includes/pledge.php b/plugins/wporg-5ftf/includes/pledge.php index fb6f178..453a14e 100755 --- a/plugins/wporg-5ftf/includes/pledge.php +++ b/plugins/wporg-5ftf/includes/pledge.php @@ -436,14 +436,11 @@ function filter_query( $query ) { break; default: - $query->set( 'orderby', 'rand' ); + $date = date( 'YmdH' ); + $query->set( 'orderby', "RAND($date)" ); break; } } - - // todo remove this when `rand` pagination fixed - // see https://github.com/WordPress/five-for-the-future/issues/70#issuecomment-549066883. - $query->set( 'posts_per_page', 100 ); } /**