Skip to content

Commit

Permalink
Actually use orderby and order in remote_get()
Browse files Browse the repository at this point in the history
  • Loading branch information
helen committed Jul 18, 2019
1 parent 27ab5c9 commit a57f12e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ public function remote_get( $args = array() ) {
if ( ! empty( $args['s'] ) ) {
$query_args['search'] = $args['s'];
}

if ( ! empty( $args['orderby'] ) ) {
if ( 'post__in' === $args['orderby']) {
$query_args['orderby'] = 'include';
} else {
$query_args['orderby'] = strtolower( $args['orderby'] );
}
}

if ( ! empty( $args['order'] ) ) {
$query_args['order'] = strtolower( $args['order'] );
}
}

static $types_urls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,14 @@ public function remote_get( $args = array() ) {
$query_args['s'] = $args['s'];
}

if ( ! empty( $args['orderby'] ) ) {
$query_args['orderby'] = $args['orderby'];
}

if ( ! empty( $args['order'] ) ) {
$query_args['order'] = $args['order'];
}

$posts_query = new \WP_Query( apply_filters( 'dt_remote_get_query_args', $query_args, $args, $this ) );

$posts = $posts_query->posts;
Expand Down

0 comments on commit a57f12e

Please sign in to comment.