Dynamically import posts from one wordpress site to another

I see you posted you found a solution, but just to add for others (and in case you’re interested in another method):

You could hook Site A on the post’s status change to Published to POST all relevant post data to an endpoint on Site B’s api you’ve set up to function as a webhook.

(Authenticating can be done on this endpoint as well with a permissions callback that is called before the callback).

You can send/receive everything as json, or handle it like a form $_POST if you prefer, of course.

If you’re just migrating, rather than keeping in sync, you could also reverse that flow and have Site B grab and process an endpoint on Site A that has all relevant posts.


I give a rough example in this WPSE answer after the heading “Import Bridge with WP-JSON API” if you want to look at some mocked up code on what I’m talking about.


I’ve also found this resource for WP_REST request class methods quite useful.

And of course there is the
WordPress wp-json developer handbook for a walkthrough.