Function Reference: geodir_location_seo_by_slug
Summary
Get location SEO information using location slug.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
Package
GeoDirectory_Location_Manager
Parameters
- $slug
- (string) (required) Location slug.
- Default: None
- $location_type
- (string) (required) Location type. Possible values ‘gd_city’,’gd_region’,’gd_country’.
- Default: None
- $country_slug
- (string) (required) Country slug.
- Default: None
- $region_slug
- (string) (required) Region slug.
- Default: None
Return Values
- (mixed|null)
Change Log
Since: 1.0.0
Source File
geodir_location_seo_by_slug() is located in geodir_location_manager/geodir_location_functions.php [Line: 770]
Source Code
function geodir_location_seo_by_slug($slug, $location_type='city', $country_slug='', $region_slug='')
{
global $wpdb;
if ($slug=='') {
return NULL;
}
$whereField = '1';
$whereVal = array();
switch($location_type) {
case 'country': {
$whereField .= ' AND location_type=%s AND country_slug=%s';
$whereVal[] = $location_type;
$whereVal[] = $slug;
}
break;
case 'region': {
$whereField .= ' AND location_type=%s AND region_slug=%s';
$whereVal[] = $location_type;
$whereVal[] = $slug;
if ($country_slug!='') {
$whereField .= ' AND country_slug=%s';
$whereVal[] = $country_slug;
}
}
break;
case 'city': {
$whereField .= ' AND location_type=%s AND city_slug=%s';
$whereVal[] = $location_type;
$whereVal[] = $slug;
if ($country_slug!='') {
$whereField .= ' AND country_slug=%s';
$whereVal[] = $country_slug;
}
if ($region_slug!='') {
$whereField .= ' AND region_slug=%s';
$whereVal[] = $region_slug;
}
}
break;
}
if (empty($whereVal)) {
return NULL;
}
$sql = $wpdb->prepare( "SELECT seo_id, seo_title, seo_desc FROM ".LOCATION_SEO_TABLE." WHERE ".$whereField." ORDER BY seo_id LIMIT 1", $whereVal );
$row = $wpdb->get_row($sql);
if (is_object($row)) {
return $row;
}
return NULL;
}