Function Reference: geodir_default_where

Summary

Listing location where filter.

Global Values

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

Default: None
$wpdb
(object) (required) WordPress Database object.

Default: None
$table_prefix
(string) (required) WordPress Database Table prefix.

Default: None

Package

GeoDirectory

Parameters

$where
(string) (required) The where query string.

Default: None

Return Values

(string)
  • Modified where query string.

Change Log

Since: 1.0.0

Source File

geodir_default_where() is located in geodirectory-functions/listing_filters.php [Line: 679]

Source Code

function geodir_default_where($where)
{
    global $wp_query, $wpdb;

    //print_r($wp_query);
    ########### WPML ###########

    if (geodir_is_wpml()) {
        global $sitepress, $table_prefix;
        $lang_code = ICL_LANGUAGE_CODE;
        $default_lang_code = $sitepress->get_default_language();
        $q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : '';
        //echo '##########'.$q_post_type;
        if ($lang_code && $q_post_type && geodir_wpml_is_post_type_translated($q_post_type)) {
            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_" . $q_post_type . "') ";
            //$where .= " AND icl_t.language_code = '$lang_code' ";
        }

    }
    ########### WPML ###########


    return $where = str_replace("0 = 1", "1=1", $where);

    /* ====== old code start ===
    $where = str_replace("0 = 1", "1=1", $where);
    $country = get_query_var('gd_country');
    $region = get_query_var('gd_region');
    $city = get_query_var('gd_city');
    $neighbourhood = get_query_var('gd_neighbourhood');


    if($country != '')
        $where .= " AND ".POST_LOCATION_TABLE.".country_slug = '".$country."' ";

    if($region != '')
        $where .= " AND ".POST_LOCATION_TABLE.".region_slug = '".$region."' ";

    if($city != '')
        $where .= " AND ".POST_LOCATION_TABLE.".city_slug = '".$city."' ";

    if($neighbourhood != '')
        $where .= " AND ".$table.".post_neighbourhood = '".$neighbourhood."' ";

    return $where;
    /* === old code end ===*/

}