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
This commit is contained in:
Kelly Dwan 2019-12-13 15:41:00 -05:00 committed by GitHub
parent e9aeb72c9b
commit 3b97459b15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 );
}
/**