Function Reference: geodir_listing_loop_location_filter

Summary

Adds location filter to the query.

Global Values

$wp_query
(object) (required) WordPress Query object.

Default: None
$plugin_prefix
(string) (required) Geodirectory plugin table prefix.

Default: None

Package

GeoDirectory_Location_Manager

Parameters

$query
(object) (required) The WP_Query instance.

Default: None

Change Log

Since: 1.0.0

Source File

geodir_listing_loop_location_filter() is located in geodir_location_manager/geodir_location_hooks_actions.php [Line: 1388]

Source Code

function geodir_listing_loop_location_filter( $query ) {
	global $wp_query, $geodir_post_type, $table, $plugin_prefix, $table, $term;
	
	// fix wp_reset_query for popular post view widget
	if ( !geodir_is_geodir_page() ) {
		return;
	}
	
	$apply_location_filter = true ;
	if( isset( $query->query_vars['gd_location'] ) ) {
		$apply_location_filter = $query->query_vars['gd_location'] ? true : false ;
	}
	
	if ( isset( $query->query_vars['is_geodir_loop'] ) && $query->query_vars['is_geodir_loop']  && !is_admin() && !geodir_is_page( 'add-listing' ) && !isset( $_REQUEST['geodir_dashbord'] ) && $apply_location_filter ) {
		geodir_post_location_where(); // this function is in geodir_location_functions.php
	}	
}