I would like to automatically sync WP posts with existing Discourse topics if they have the same name. How to get a topic by title?

AI-generated summary

Syncing WP Posts with Existing Discourse Topics

Canapin is seeking a way to automatically sync their ~200 WordPress (WP) posts with existing Discourse topics that have the same name. To achieve this, they need to retrieve topics by their title while minimizing the risk of mismatches.

Simon suggests two possible approaches:

  1. Manual syncing using the method described in this meta thread.
  2. Writing a script that calls a function similar to the one found in wp-discourse’s meta-box.php. This would involve making a request to the Discourse topic without the ID and getting the redirect returned by Discourse, using a command like curl http://localhost:3000/t/your-topic-without-the-id -s -L -I -o /dev/null -w '%{url_effective}'

Hi.
I have ~200 articles on my WP.
I also have topics with the same name on my Discourse, from a phpbb import.

The phpbb topics were created when new articles were published in our previous CMS.

I’d like to sync all these old WP posts to these Discourse topics.

How would you do that? Not specifically how to call the sync, but rather how to get the topics from their title, while minimizing the risk of mismatches? I’m pretty confident that the WP posts and Discourse topic have the exact same title.

Should I use the Discourse search, get the first result and compare the title?

You could do it manually with this:

Or write a script that calls a function similar to this:

Since you only have the topic titles, and not the topic ids, I think you’ll need to make a request to the Discourse topic without the id and get the redirect that’s returned from Discourse. Something like curl http://localhost:3000/t/your-topic-without-the-id -s -L -I -o /dev/null -w '%{url_effective}'