The auto categorization system creates hierarchical WordPress taxonomy structures for properties based on RETS data. It generates area/subarea categories, property type categories, and SEO-friendly URL slug structures for organized property browsing.
// Property Category Taxonomy (hierarchical)
register_taxonomy('property_category', 'property', [
'hierarchical' => true,
'labels' => [
'name' => __('Category', 'es-plugin'),
'singular_name' => __('Category', 'es-plugin'),
],
'public' => true,
'show_ui' => true,
'show_in_rest' => true,
'rewrite' => [
'slug' => 'mls',
'with_front' => false,
],
]);
// Property Tag Taxonomy (non-hierarchical)
register_taxonomy('property_tag', 'property', [
'hierarchical' => false,
'label' => __('Tags', 'esh'),
'rewrite' => [
'slug' => 'mls/tag',
'with_front' => false,
],
]);
// Bridge API property class mapping
if ($property_type == 'Residential' &&
strpos($structure_type, 'Residential Detached') !== false) {
$property_class = 'RD_1';
} elseif ($property_type == 'Residential' &&
strpos($structure_type, 'Residential Attached') !== false) {
$property_class = 'RA_2';
} elseif ($property_type == 'Residential Income') {
$property_class = 'MF_3';
} elseif ($property_type == 'Land') {
$property_class = 'LD_4';
}
// Type determination based on dwelling
if (($property_class == 'RD_1' || $property_class == 'RA_2')) {
if ($type_of_dwelling == 'Townhouse') {
$type = 'Townhouses';
} elseif ($type_of_dwelling == 'Apartment/Condo') {
$type = 'Condos';
} else {
$type = 'House';
}
}
// Create area categories without types for autocomplete
if (!empty($area)) {
$term_parent = wp_set_object_terms($this->_entity->getID(), $area, 'property_category', true);
if (!is_wp_error($term_parent)) {
$term_parent_tid = reset($term_parent);
update_term_meta($term_parent_tid, 'autocomplete', 1);
update_term_meta($term_parent_tid, 'breadcrumb_name', $area);
update_term_meta($term_parent_tid, 'area', $area);
update_term_meta($term_parent_tid, 'category_type', 'area');
// Create subarea if exists
if (!empty($sub_area)) {
$term = wp_set_object_terms($this->_entity->getID(),
$area . ' ' . $sub_area,
'property_category', true);
if (!is_wp_error($term)) {
$term_tid = reset($term);
update_term_meta($term_tid, 'autocomplete', 1);
update_term_meta($term_tid, 'breadcrumb_name', $area . ' ' . $sub_area);
update_term_meta($term_tid, 'area', $area);
update_term_meta($term_tid, 'category_type', 'subarea');
wp_update_term($term_tid, 'property_category', [
'parent' => $term_parent_tid,
]);
}
}
}
}
| Data Component | Bridge API Fields | Legacy RETS Fields | Usage |
|---|---|---|---|
| Area | MLSAreaMajor | L_Area | Main geographic region |
| Sub Area | MLSAreaMinor | LM_Char10_5 | Subdivision within area |
| Property Type | PropertyType, StructureType | LM_char1_36 | Property classification |
| Dwelling Type | PropertySubType | LM_Char10_11 | Specific property style |
// Extract categorization data
$property_class = $this->_class;
$prop_type = $this->_data['LM_char1_36'];
$type_of_dwelling = $this->_data['LM_Char10_11'];
$area = $this->_data['L_Area'];
$sub_area = $this->_data['LM_Char10_5'];
// Bridge API adjustments
if ($is_bridge_api) {
$property_type = $this->_data['PropertyType'];
$property_sub_type = $this->_data['PropertySubType'];
$structure_type = $this->_data['StructureType'];
$prop_type = $structure_type;
$type_of_dwelling = $property_sub_type;
$area = $this->_data['MLSAreaMajor'];
$sub_area = $this->_data['MLSAreaMinor'];
}
Single-family houses, houses with acreage
Condos, townhouses, attached units
Residential income properties
Lots, land only properties
// Term meta fields for enhanced functionality
update_term_meta($term_id, 'autocomplete', 1);
update_term_meta($term_id, 'breadcrumb_name', $display_name);
update_term_meta($term_id, 'area', $area_value);
update_term_meta($term_id, 'type', $property_type);
update_term_meta($term_id, 'category_type', $classification);
// Category type classifications:
// 'area' - Geographic area only
// 'subarea' - Geographic subarea only
// 'area+type' - Area combined with property type
// 'subarea+type' - Subarea combined with property type
Enables category in search autocomplete functionality
Display name used in breadcrumb navigation
Classification for different category hierarchy levels
// Area + Type combination creation
if (!empty($type)) {
$term = $area . ' ' . $type;
$t = wp_set_object_terms($this->_entity->getID(), $term, 'property_category', true);
if (!is_wp_error($t) && $t) {
$t = reset($t);
update_term_meta($t, 'breadcrumb_name', $area);
update_term_meta($t, 'area', $area);
update_term_meta($t, 'type', $type);
update_term_meta($t, 'category_type', 'area+type');
if (!empty($term_parent)) {
wp_update_term($t, 'property_category', [
'parent' => $term_parent,
]);
}
}
}
$keywords = '';
// Add MLS number
if ($mls = get_post_meta($post_id, 'fave_mls_no', true)) {
$keywords .= $mls . ' ';
}
// Add address
if ($address = get_post_meta($post_id, 'fave_property_map_address', true)) {
$keywords .= $address . ' ';
}
// Add categories
if ($categories = wp_get_object_terms($post_id, 'property_category', ['fields' => 'names'])) {
$keywords .= implode(', ', $categories) . ' ';
}
// Add cities
if ($cities = wp_get_object_terms($post_id, 'property_city', ['fields' => 'names'])) {
$keywords .= implode(', ', $cities);
}
// Save as custom keyword meta
update_post_meta($post_id, 'fave_custom_keyword', $keywords);
// Assign property type taxonomy
if (!empty($type)) {
wp_set_object_terms($this->_entity->getID(),
$type,
'property_type',
true);
// Also add to property_tag for tagging
wp_set_object_terms($this->_entity->getID(),
$type,
'property_tag',
true);
}
Categories with autocomplete=1 appear in search suggestions
Hierarchical categories enable drill-down property browsing
Custom keywords enhance search engine visibility
Slug: 'mls' with with_front: false
Slug: 'mls/tag'
Descriptive URLs that clearly indicate content hierarchy
Enhanced user experience with clear navigation paths
Clean URL structure improves search engine crawling
| Category Type | Example Category | Generated URL | Purpose |
|---|---|---|---|
| area | Toronto | /mls/toronto/ | Geographic browsing |
| area+type | Toronto Condos | /mls/toronto-condos/ | Filtered by type |
| subarea+type | Toronto Downtown Condos | /mls/toronto-downtown-condos/ | Specific location + type |
| tag | 3 Bedrooms | /mls/tag/3-bedrooms/ | Feature-based filtering |