Pledge List: Sort randomly by default for fairness.

See #70
This commit is contained in:
Ian Dunn 2019-11-02 13:26:22 -05:00
parent bac15d21fc
commit 11b9bf3604
No known key found for this signature in database
GPG key ID: 99B971B50343CBCB
2 changed files with 8 additions and 1 deletions

View file

@ -260,6 +260,13 @@ function filter_query( $query ) {
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'order', 'DESC' );
break;
default:
$query->set( 'orderby', 'rand' );
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 );
}

View file

@ -32,7 +32,7 @@ get_header(); ?>
<label for="pledge-sort"><?php esc_html_e( 'Sort pledges by', 'wordpressorg' ); ?></label>
<select class="custom-select" id="pledge-sort" name="order">
<option value="" <?php selected( $pledge_order, '' ); ?>>
<?php esc_html_e( 'All Pledges', 'wordpressorg' ); ?>
<?php esc_html_e( 'Random', 'wordpressorg' ); ?>
</option>
<option value="alphabetical" <?php selected( $pledge_order, 'alphabetical' ); ?>>
<?php esc_html_e( 'Alphabetical', 'wordpressorg' ); ?>