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.

1
  • As long as there is a data feed (JSON/XML) then I've a feeling the WP All Import plugin can do what you're looking for. I've not used if for a while, but when I did it worked really well. It is a paid plugin. wpallimport.com Commented Feb 18, 2021 at 14:20

1 Answer 1

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!

1
  • 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
    Commented Feb 28, 2017 at 3:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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