Pledge List: Add sorting by total contributor count

Allow sorting the pledge archive by total number of confirmed contributors.
This commit is contained in:
Kelly Dwan 2019-12-11 16:41:36 -05:00
parent e9aeb72c9b
commit fea1621cf9
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D
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:
$query->set( 'orderby', 'rand' );
break;

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>