GeoDirectory sorts search results automatically and does not show a sort dropdown on the search page. You can still change the order with a URL parameter or a small snippet.
How search results are ordered
- If the visitor searched near a location, results are ordered by distance, nearest first.
- If there is no location but there is a keyword, results are ordered by best match for that keyword.
- With neither, the default sort for the post type is used. You set that in Places > Settings > Sorting.
The sort options you set up in Places > Settings > Sorting appear on category and archive pages, not on the search page. See changing or adding new sorting options.
Sort with the sort_by parameter
The search page accepts a sort_by parameter. Add it to a search URL and the results use that order instead, for example &sort_by=high_rating. Values you can use include:
high_ratingfor highest ratinghigh_reviewfor most reviewslatestfor newest firstazandzafor title orderpost_modified_descfor recently updatedrandom
Add a sort dropdown to the search bar
This snippet adds a “Sort by” select to the GD > Search bar, so visitors choose the order before they search. Add it with a code snippets plugin.
add_action( 'geodir_before_search_button', function() {
$current = isset( $_REQUEST['sort_by'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['sort_by'] ) ) : '';
$options = array(
'' => __( 'Best match', 'geodirectory' ),
'high_rating' => __( 'Highest rating', 'geodirectory' ),
'high_review' => __( 'Most reviews', 'geodirectory' ),
'latest' => __( 'Latest', 'geodirectory' ),
'az' => __( 'A-Z', 'geodirectory' ),
);
echo '<div class="col-auto"><select name="sort_by" class="form-select form-control" aria-label="Sort by">';
foreach ( $options as $value => $label ) {
echo '<option value="' . esc_attr( $value ) . '"' . selected( $current, $value, false ) . '>' . esc_html( $label ) . '</option>';
}
echo '</select></div>';
} );
Leaving it on “Best match” keeps the automatic order described above, including nearest first when a location is entered.