Ecommerce Shopify WordPress Discussion

Need input on a custom development solution I'm working on – Estatik Real Estate

I have a wordpress multisite and I have the Estatik Real Estate premium plugin (utilizing the MLS sync function). I had originally intended to give every one of their agents a site, however, it ended up requiring that I duplicate all of the properties on each of the websites, which is leading to a significantly large database. To fix this, I am setting up 1 site on the multisite to handle the MLS import and then access that data from the child sites. I want to be able to utilize the functionality within the Estatik plugin for things like searching, map display, and all the other front-end nice items it comes with. To accomplish this, I have done the following: Since the properties are stored as a custom post type and they are also stored in the normal post and postmeta tables, i have: cloned the plugin to my own custom version for the agent sites that I will maintain. made edits to the php files within the custom plugin to switch to the database tables any time the property post type is being called to the central MLS website. You can see the status of this here: The MLS-Synced site: Here is the site that draws from the centralized property site: I have a function I am using to intercept post types for single property views. The issue here is that I am not getting all the property meta and sections. You can see this by viewing a property on the MLS-Synced site and comparing it to the same property viewed through the agent site. I need a direction on how to fix this. I am trying to hook in and out at the right times to not break any data outside the main page. Any thoughts on my solution, suggestions, or otherwise, I am all ears! Thank you Here is my current interception code for single properties: // Class to handle table redirection and logging class TableRedirectionManager { private $central_site_table_prefix; private $original_tables = []; public function __construct($table_prefix) { $this->central_site_table_prefix = $table_prefix; } public function log_message($message, $is_error = false) { if (WP_DEBUG === true) { $log_function = $is_error ? 'error_log' : 'error_log'; $log_function($message); } } public function redirect_property_queries($query) { global $wpdb; // Ensure $query is an instance of WP_Query if (!($query instanceof WP_Query)) { $this->log_message('Expected WP_Query object, received: ' . gettype($query)); return; } // Backup original table names $this->original_tables = [ 'posts' => $wpdb->posts, 'postmeta' => $wpdb->postmeta, 'estatik_fb_fields' => $wpdb->estatik_fb_fields, 'estatik_fb_sections' => $wpdb->estatik_fb_sections ]; if ($query->get('post_type') === 'properties') { $this->redirect_tables($wpdb); $this->log_message("Redirected property queries to central site tables."); add_filter('the_posts', function($posts) use ($wpdb) { $this->reset_tables($wpdb); $this->log_message("Reset table names to original after query."); return $posts; }, 10, 2); } } private function redirect_tables(&$wpdb) { $wpdb->posts = $this->central_site_table_prefix . 'posts'; $wpdb->postmeta = $this->central_site_table_prefix . 'postmeta'; $wpdb->estatik_fb_fields = $this->central_site_table_prefix . 'estatik_fb_fields'; $wpdb->estatik_fb_sections = $this->central_site_table_prefix . 'estatik_fb_sections'; } private function reset_tables(&$wpdb) { foreach ($this->original_tables as $key => $value) { $wpdb->$key = $value; } } } // Initialize the redirection manager $table_prefix = 'wp_52_'; // Replace with your central site's table prefix $redirection_manager = new TableRedirectionManager($table_prefix); // Hook into pre_get_posts for normal requests. add_action('pre_get_posts', function ($query) use ($redirection_manager) { $redirection_manager->redirect_property_queries($query); }); // Hook into es_before_single_wrapper for normal requests. add_action('es_before_single_wrapper', function () use ($redirection_manager) { global $wp_query; $redirection_manager->redirect_property_queries($wp_query); }); // Hook into es_before_single_wrapper for normal requests. add_action('es_property_meta', function () use ($redirection_manager) { global $wp_query; $redirection_manager->redirect_property_queries($wp_query); }); // Hook into es_before_single_wrapper for normal requests. add_action('es_property_control', function () use ($redirection_manager) { global $wp_query; $redirection_manager->redirect_property_queries($wp_query); }); // Hook into es_before_single_wrapper for normal requests. add_action('es_single_property_layout', function () use ($redirection_manager) { global $wp_query; $redirection_manager->redirect_property_queries($wp_query); }); // Hook into es_before_single_wrapper for normal requests. add_action('es_before_entities', function () use ($redirection_manager) { global $wp_query; $redirection_manager->redirect_property_queries($wp_query); }); // Hook into es_before_single_wrapper for normal requests. add_action('es_single_property_section', function () use ($redirection_manager) { global $wp_query; $redirection_manager->redirect_property_queries($wp_query); });
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.