Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Forked from anonymous/Ordering depending on distance selection
Last active August 14, 2017 13:03
Show Gist options
  • Save mgibbs189/4970194412173dd0152293661ad9d2b9 to your computer and use it in GitHub Desktop.
Save mgibbs189/4970194412173dd0152293661ad9d2b9 to your computer and use it in GitHub Desktop.
Ordering depending on distance selection
<?php
add_filter( 'facetwp_query_args', function( $query_args, $class ) {
if ( 0 < count( $class->facets['distance']['selected_values'] ) ) {
$query_args['orderby'] = 'post__in';
$query_args['order'] = 'ASC';
}
return $query_args;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment