Skip to content

Instantly share code, notes, and snippets.

@ChrisFlannagan
Created April 18, 2018 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisFlannagan/42488c578c3a9167ee2a7290f937d358 to your computer and use it in GitHub Desktop.
Save ChrisFlannagan/42488c578c3a9167ee2a7290f937d358 to your computer and use it in GitHub Desktop.
<?php
add_filter( 'rest_product_query', function( $query_args, $request ) {
if ( isset( $_GET['search'] ) && ! empty( $_GET['search'] ) && class_exists( '\SWP_Query' ) ) {
$query_args['orderby'] = 'post__in';
}
return $query_args;
}, 99, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment