0

I have a custom MySQL DB(same host/different domain) with a lot of vehicle information.

What we want to do is populate a custom post type and custom fields with this data so that it's SEO friendly in WP. Is there any way to do this in WordPress? Basically have WP look at this table to populate the custom post type. We will NOT be using WP to manage this data. When the data is updated in this table, it should automatically be updated in WP.

So basically not an import, just read off of the other table. If it helps, we do have a REST API built too.

I'm hoping what I'm saying makes sense. If it doesn't, please feel free to ask me questions. This is a pretty big deal to us and we really want to figure out the best solution.

bumped to the homepage by Community yesterday

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

0

So the best way here would be for your other system to "call" WordPress any time something changes... You could build a WordPress plugin that listens for a specific ajax call and upon receiving the new data, it could create / update the custom post type in your WordPress site.

Some things to remember:

  • Make sure you have some kind of handshake mechanism (like a private key or something) otherwise anyone could start creating posts in your system!
  • Make sure to pass on a unique ID for each record, that you will save as a custom field in WordPress, so you can update existing records instead of creating new ones.

A less elegant solution, would be for WordPress to poll your system every so often, and ask it for anything new. In this case, your WordPress plugin would need to save the date of its last request, so it can ask your main system for any changes since that last call. Your main system would return a list of updated record, and the plugin could create/update each custom post accordingly.

To poll from WordPress, your plugin can install a schedule for wp-cron

This is going to be a bit less elegant and efficient because WordPress will be asking every so often if anything's changed. This means it will potentially ask too often and waste cycles, (if things don't change often in the main system) or not often enough, and your WordPress data will be stale.

Hope this helps!

  • Thank you for your answer. I was thinking a cron would be good. However, I found out that we have several thousand customers updating their records throughout the day. So at any given time there's hundreds of updates on the DB. I think anything with a cron would just timeout or crash the server. My only other thought would be to have the Windows software post 2 updates to each separate DB. Although this could be problematic as well. Only because each customer has their own unique ID and we'd have to reach out to multiple WP DB's. Not sure how we'd structure that functionality – lz430 Feb 28 '17 at 3:15

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.