// PROPERTY CUSTOM POST TYPE FOR SEO function register_property_post_type() { $labels = array( 'name' => 'Properties', 'singular_name' => 'Property', 'menu_name' => 'Properties', 'add_new' => 'Add New Property', 'add_new_item' => 'Add New Property', 'edit_item' => 'Edit Property', 'new_item' => 'New Property', 'view_item' => 'View Property', 'search_items' => 'Search Properties', 'not_found' => 'No properties found', 'not_found_in_trash' => 'No properties found in trash', ); $args = array( 'labels' => $labels, 'public' => true, // SEO CRITICAL: Makes posts visible to search engines 'publicly_queryable' => true, // SEO CRITICAL: Allows individual property pages 'show_ui' => true, // Shows in WordPress admin 'show_in_menu' => true, // Shows in admin menu 'query_var' => true, 'rewrite' => array('slug' => 'property'), // SEO-friendly URLs: /property/property-name/ 'capability_type' => 'post', 'has_archive' => true, // SEO CRITICAL: Creates /property/ archive page 'hierarchical' => false, 'menu_position' => 5, 'menu_icon' => 'dashicons-building', 'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'), 'show_in_rest' => true, // Enables Gutenberg editor 'taxonomies' => array('property_type', 'district'), // For RankMath categorization ); register_post_type('property', $args); } add_action('init', 'register_property_post_type'); // PROPERTY TAXONOMIES FOR SEO CATEGORIZATION function register_property_taxonomies() { // Property Type taxonomy (Sale/Rent/etc) register_taxonomy('property_type', 'property', array( 'labels' => array( 'name' => 'Property Types', 'singular_name' => 'Property Type', ), 'public' => true, 'hierarchical' => true, 'rewrite' => array('slug' => 'type'), 'show_in_rest' => true, )); // District taxonomy for location-based SEO register_taxonomy('district', 'property', array( 'labels' => array( 'name' => 'Districts', 'singular_name' => 'District', ), 'public' => true, 'hierarchical' => true, 'rewrite' => array('slug' => 'district'), 'show_in_rest' => true, )); } add_action('init', 'register_property_taxonomies'); // COMPLETE the function you started function update_all_property_posts_to_published() { $args = array( 'post_type' => 'property', 'post_status' => 'draft', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'property_number', 'compare' => 'EXISTS' ) ) ); $properties = get_posts($args); foreach($properties as $property) { wp_update_post(array( 'ID' => $property->ID, 'post_status' => 'publish' // SEO CRITICAL: Makes posts visible to search engines )); echo "Published property: " . $property->post_title . "
"; } echo "Updated " . count($properties) . " properties to published status."; } // PROPERTY CUSTOM POST TYPE FOR SEO function register_property_post_type() { $labels = array( 'name' => 'Properties', 'singular_name' => 'Property', 'menu_name' => 'Properties', 'add_new' => 'Add New Property', 'add_new_item' => 'Add New Property', 'edit_item' => 'Edit Property', 'new_item' => 'New Property', 'view_item' => 'View Property', 'search_items' => 'Search Properties', 'not_found' => 'No properties found', 'not_found_in_trash' => 'No properties found in trash' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_rest' => true, // For Gutenberg editor 'query_var' => true, 'rewrite' => array('slug' => 'property', 'with_front' => false), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => 5, 'menu_icon' => 'dashicons-building', 'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'custom-fields'), 'show_in_nav_menus' => true, 'can_export' => true, 'exclude_from_search' => false // IMPORTANT FOR SEO! ); register_post_type('property', $args); } add_action('init', 'register_property_post_type'); // CREATE PROPERTY POSTS FROM DATABASE FOR SEO function sync_properties_to_posts($limit = 50) { global $wpdb; // Get properties that don't have posts yet $properties = $wpdb->get_results(" SELECT u.*, e.E_ESTATE, e.C_ESTATE, d.E_DISTRICT, d.C_DISTRICT FROM UPLOADPROP u LEFT JOIN ESTATE e ON u.ESTATE = e.ESTATE LEFT JOIN DISTRICT d ON u.DISTRICT = d.DISTRICT LEFT JOIN {$wpdb->posts} p ON p.post_name = CONCAT('property-', u.NUMBER) WHERE p.ID IS NULL AND u.DELETEDATE = 0 AND u.STATUS IN ('Available', 'available', 'AVAILABLE') LIMIT $limit "); $created_count = 0; foreach ($properties as $property) { // Create SEO-friendly title $title = create_property_title($property); // Create SEO-friendly content $content = create_property_content($property); // Create SEO-friendly excerpt $excerpt = create_property_excerpt($property); // Create the post $post_data = array( 'post_title' => $title, 'post_content' => $content, 'post_excerpt' => $excerpt, 'post_status' => 'publish', 'post_type' => 'property', 'post_name' => 'property-' . $property->NUMBER, // SEO-friendly URL 'meta_input' => array( 'property_number' => $property->NUMBER, 'property_price' => $property->PRICE, 'property_rent' => $property->RENT, 'property_area' => $property->GROSSAREA, 'property_type' => $property->E_PROPTYPE, 'property_district' => $property->E_DISTRICT, 'property_estate' => $property->E_ESTATE, 'property_building' => $property->E_BUILDING, 'property_bedrooms' => $property->BEDROOM, 'property_bathrooms' => $property->BATHROOM, 'property_floor' => $property->FLOOR, 'property_unit' => $property->UNIT ) ); $post_id = wp_insert_post($post_data); if (!is_wp_error($post_id)) { $created_count++; // Set property category taxonomy if needed wp_set_object_terms($post_id, array($property->E_PROPTYPE), 'property_type'); wp_set_object_terms($post_id, array($property->E_DISTRICT), 'property_location'); } } return $created_count; } // CREATE SEO-FRIENDLY PROPERTY TITLE function create_property_title($property) { $parts = array(); // Property type if (!empty($property->E_PROPTYPE)) { $parts[] = $property->E_PROPTYPE; } // Bedrooms if (!empty($property->BEDROOM) && $property->BEDROOM > 0) { $parts[] = $property->BEDROOM . ' Bedroom'; } // Area if (!empty($property->GROSSAREA) && $property->GROSSAREA > 0) { $parts[] = number_format($property->GROSSAREA) . ' sq ft'; } // Location if (!empty($property->E_ESTATE)) { $parts[] = 'in ' . $property->E_ESTATE; } elseif (!empty($property->E_DISTRICT)) { $parts[] = 'in ' . $property->E_DISTRICT; } // Action type $action = (!empty($property->RENT) && $property->RENT > 0) ? 'for Rent' : 'for Sale'; $parts[] = $action; return implode(' ', $parts); } // CREATE SEO-FRIENDLY PROPERTY CONTENT function create_property_content($property) { $content = '
'; // Main description $content .= '

Property Overview

'; $content .= '

This beautiful ' . strtolower($property->E_PROPTYPE) . ' is located in the prime area of ' . $property->E_DISTRICT . ', Hong Kong.

'; // Key features $content .= '

Key Features

'; $content .= ''; // Price information $content .= '

Price Information

'; if (!empty($property->PRICE) && $property->PRICE > 0) { $content .= '

Sale Price: HK$' . number_format($property->PRICE) . '

'; } if (!empty($property->RENT) && $property->RENT > 0) { $content .= '

Monthly Rent: HK$' . number_format($property->RENT) . '

'; } // Location details $content .= '

Location

'; $content .= '

District: ' . $property->E_DISTRICT . '

'; if (!empty($property->E_ESTATE)) { $content .= '

Estate: ' . $property->E_ESTATE . '

'; } if (!empty($property->E_BUILDING)) { $content .= '

Building: ' . $property->E_BUILDING . '

'; } // Additional remarks if (!empty($property->E_REMARKS)) { $content .= '

Additional Information

'; $content .= '

' . $property->E_REMARKS . '

'; } $content .= '
'; return $content; } // CREATE SEO-FRIENDLY PROPERTY EXCERPT function create_property_excerpt($property) { $excerpt_parts = array(); $excerpt_parts[] = $property->E_PROPTYPE; if (!empty($property->BEDROOM) && $property->BEDROOM > 0) { $excerpt_parts[] = $property->BEDROOM . ' bedroom'; } if (!empty($property->GROSSAREA) && $property->GROSSAREA > 0) { $excerpt_parts[] = number_format($property->GROSSAREA) . ' sq ft'; } $excerpt_parts[] = 'in ' . $property->E_DISTRICT; $action = (!empty($property->RENT) && $property->RENT > 0) ? 'for rent' : 'for sale'; $excerpt_parts[] = $action; $price = (!empty($property->RENT) && $property->RENT > 0) ? 'HK$' . number_format($property->RENT) . '/month' : 'HK$' . number_format($property->PRICE); return implode(' ', $excerpt_parts) . '. ' . $price . '.'; } // PROPERTY TAXONOMIES FOR BETTER SEO function register_property_taxonomies() { // Property Type taxonomy register_taxonomy('property_type', 'property', array( 'hierarchical' => true, 'labels' => array( 'name' => 'Property Types', 'singular_name' => 'Property Type' ), 'show_ui' => true, 'show_in_rest' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array('slug' => 'type') )); // Property Location taxonomy register_taxonomy('property_location', 'property', array( 'hierarchical' => true, 'labels' => array( 'name' => 'Locations', 'singular_name' => 'Location' ), 'show_ui' => true, 'show_in_rest' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array('slug' => 'location') )); } add_action('init', 'register_property_taxonomies'); // ADMIN FUNCTION TO SYNC PROPERTIES function add_property_sync_admin_page() { add_submenu_page( 'edit.php?post_type=property', 'Sync Properties', 'Sync Properties', 'manage_options', 'sync-properties', 'property_sync_admin_page' ); } add_action('admin_menu', 'add_property_sync_admin_page'); function property_sync_admin_page() { if (isset($_POST['sync_properties'])) { $count = sync_properties_to_posts(100); echo '

Created ' . $count . ' property posts!

'; } echo '
'; echo '

Sync Properties to Posts

'; echo '

This will create WordPress posts from your property database for SEO optimization.

'; echo '
'; echo ''; echo '
'; echo '
'; } // AUTO-SYNC PROPERTIES (Optional - can be run via cron) function auto_sync_properties() { sync_properties_to_posts(20); // Sync 20 at a time } // add_action('wp', 'schedule_property_sync'); function schedule_property_sync() { if (!wp_next_scheduled('auto_sync_properties')) { wp_schedule_event(time(), 'hourly', 'auto_sync_properties'); } } add_action('auto_sync_properties', 'auto_sync_properties'); Page Not Found - PODIUM Property Agency
List Your Property

Oh oh! Page not found.

We're sorry, but the page you are looking for doesn't exist. You can search your topic using the box below or return to the homepage.

Back to Homepage

Compare listings

Compare

List Your Property

Property Information

Enquiry

Enquiry for: