1

I'm building an Estate Agent website. They have a system where they add their available properties and sends them all to the main property portals.

As part of this, the system also sends all the properties to this website I'm building in BLM format. We then run a cron job every hour that checks and runs a script that imports the data into WordPress as a custom post type (property). We're also importing each property into the right taxonomy ("type", which has the terms "sales" and "lettings") and also importing some data into custom fields ("number of bedrooms", "lat/long", etc).

Here's the important part... we do NOT want to import ALL the data into WordPress as custom fields because it'd slow down the server, since there are hundreds of properties that get imported each hour and each property has more than 100 fields each (image paths, floorplans, status, etc).

For this reason, we have another table called blm_data that contains ALL the data for each property. Each row in that table has a field called WP_POST_ID, which matches the one in the wp_posts table. Is there anyway to include the data from the blm_data table by using the core WP_Query?

I have searched and found some interesting articles on WordPress filters such as posts_join and posts_where but I'm not too sure if this is the right thing:

How to extend WP_Query to include custom table in query?

http://simple2kx.com/wp-add-custom-table-into-join-query-with-order-by-into-wp-query-before-query_posts/

The main reason why we import the data as WordPress posts and not use custom SQL queries is to be able to use the WordPress core URL rewriting engine and custom fields.

Could someone point me in the right direction? If I use posts_join can I then retrieve data from the row matching the post ID?

Not sure if I'm doing the right thing so any pointers would be appreciated.

Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.