Is It Possible to Bulk Create Threads for Many WordPress Posts? SQL Maybe?

As others have mentioned, the easiest way of doing this currently is via the WP Discourse plugin. Updating the dbs of each instance directly raises two potential issues:

  1. It requires you to understand all of the data and metadata being stored on each instance.
  2. The data and metadata is interdependent, i.e. after a post is successfully published from Wordpress to Discourse the id of the post in Discourse is saved to a post meta field in Wordpress.

If you were already familiar with both 1 and 2, then yes updating the dbs directly might be a good option, but considering you’re not, it’s not a good idea unless you want to spend time learning that just for this purpose. In that vein, you could hire someone to do this for you, however I would recommend you just use the WP Discourse plugin’s functionality instead.

Using the WP Discourse plugin has the additional benefit of logging already being setup for WP Discourse publishing, which means you’ll get detailed, post-specific information if any of the publications fail.

It’s true that this will mean 1000-odd POST requests to your Discourse as the WP Discourse plugin only POSTs one topic at a time, however considering this is a one-time migration, you can handle this by breaking it up into batches and through pauses (i.e. sleep) in the script. I would recommend doing a manual check after the first few batches to see it’s working as you expect.

In terms of the script itself, you would use the WPDiscourse\DiscoursePublish method publish_post_after_save for each post, i.e. in a loop (with appropriate batching and sleep).

7 Likes