Pledge List: Add sorting by total contributor count (#133)

Add a "Total Contributors" option to the sorting menu on the pledge list. This will sort the list from most confirmed contributors to least.

Fixes #94
This commit is contained in:
Kelly Dwan 2019-12-16 17:48:33 -05:00 committed by GitHub
parent 183f7a95bc
commit a70212bc22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -435,6 +435,12 @@ function filter_query( $query ) {
$query->set( 'order', 'DESC' );
break;
case 'contributors':
$query->set( 'meta_key', $contributor_count_key );
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'order', 'DESC' );
break;
default:
$date = date( 'YmdH' );
$query->set( 'orderby', "RAND($date)" );

View file

@ -37,6 +37,9 @@ get_header(); ?>
<option value="alphabetical" <?php selected( $pledge_order, 'alphabetical' ); ?>>
<?php esc_html_e( 'Alphabetical', 'wporg-5ftf' ); ?>
</option>
<option value="contributors" <?php selected( $pledge_order, 'contributors' ); ?>>
<?php esc_html_e( 'Total Contributors', 'wporg-5ftf' ); ?>
</option>
<option value="hours" <?php selected( $pledge_order, 'hours' ); ?>>
<?php esc_html_e( 'Total Hours', 'wporg-5ftf' ); ?>
</option>