Skip to content

Commit

Permalink
Allow sorting by numbers
Browse files Browse the repository at this point in the history
Made a pull request of the solution from @chood531:
#65 (comment)

Fixing:  #65
  • Loading branch information
huubl committed Mar 8, 2021
1 parent f0b9d11 commit 0c675f1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/class-extended-cpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,10 @@ public static function get_sort_field_vars( array $vars, array $sortables ): arr
if ( isset( $orderby['meta_key'] ) ) {
$return['meta_key'] = $orderby['meta_key'];
$return['orderby'] = 'meta_value';
// @TODO meta_value_num

if ( isset( $orderby['meta_value_num'] ) && $orderby['meta_value_num'] ) {
$return['orderby'] = 'meta_value_num';
}
} elseif ( isset( $orderby['post_field'] ) ) {
$field = str_replace( 'post_', '', $orderby['post_field'] );
$return['orderby'] = $field;
Expand Down

0 comments on commit 0c675f1

Please sign in to comment.