Function Reference: geodir_search_widget_location_filter_orderby
Summary
Set distance sorting in widget listing query for search location filter.
Global Values
- $gd_query_args_widgets
- (array) (required) Widget query args.
- Default: None
- $snear
- (string) (required) Nearest location to search.
- Default: None
- $gd_session
- (object) (required) GeoDirectory Session object.
- Default: None
Parameters
- $orderby
- (string) (required) Orderby SQL.
- Default: None
- $table
- (string) (required) Table name.
- Default: None
- $post_type
- (string) (required) Post type.
- Default: None
Return Values
- (string)
- Modified fields SQL.
Change Log
Since: 1.6.22
Source File
geodir_search_widget_location_filter_orderby() is located in geodirectory-functions/listing_filters.php [Line: 1125]
Source Code
function geodir_search_widget_location_filter_orderby( $orderby, $table, $post_type ) { global $gd_query_args_widgets, $snear, $gd_session; if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) { $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; if ( $location_allowed && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) { $orderby = "distance ASC, " . $orderby; } } return $orderby; }