Thanks Kiran! I’ll check that out.
For now, I did end up finding a solution:
// Main args
$post_type = 'gd_place';
$args = array(
'post_type' => $post_type,
'posts_per_page' => 5
);
// Sort by highest rated using GeoDirectory query args filter
$temp_args = $args;
$geodir_sort = 'high_rating'; // or 'overall_rating_asc'
$test_instance = array (
'post_limit' => 5,
'post_type' => $post_type,
'sort_by' => $geodir_sort
);
$temp_args['is_geodir_loop'] = true;
$temp_args['order_by'] = $geodir_sort;
$temp_args = apply_filters( 'geodir_widget_listings_query_args', $temp_args, $test_instance );
$widget_listings = geodir_get_widget_listings( $temp_args );
$post_ids = array();
foreach( $widget_listings as $listing ) {
$post_ids[] = $listing->ID;
}
$args['post__in'] = $post_ids;
$args['order'] = 'DESC';
$args['orderby'] = 'post__in';
// The loop
$places = new WP_Query($args);
if ( $places->have_posts() ) :
while ( $places->have_posts() ) : $places->the_post();
echo '<div class="listing"><div class="the-title">'.get_the_title().'</div></div>';
endwhile; wp_reset_postdata();
endif;
Basically you build your query args, retrieve post ids using geodir widget query args filter, and then pull those into the main args using “post__in”.
Hope this helps someone else in the future!