# Gostaria de sincronizar automaticamente posts do WP com tópicos existentes do Discourse se tiverem o mesmo nome. Como obter um tópico pelo título?

**URL:** https://meta.discourse.org/t/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/90753
**Category:** WordPress
**Created:** [Junho 25, 2018, 11:52pm UTC](https://meta.discourse.org/t/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/90753 "2018-06-25T23:52:47Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [Junho 26, 2018, 12:12am UTC](https://meta.discourse.org/t/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/90753/2 "2018-06-26T00:12:57Z")

</div>

You could do it manually with this:

> [@Link an existing topic to a WordPress post](https://meta.discourse.org/t/link-an-existing-topic-to-a-wordpress-post/88482):
>
> The [WP Discourse](https://github.com/discourse/wp-discourse) plugin lets you link an existing Discourse topic to a WordPress post. To do this, go to the post’s edit page on WordPress and select Link to Existing Topic from the Discourse meta box. In the Topic URL field, enter the URL of a topic from your forum. You can get the URL from your browser’s address bar, or from any of the topic’s share links. (Note: you need to be on at least version 1.6.5 of the plugin to be able to use the share link URLs.) Click the WordPress Publ…

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

> <https://github.com/discourse/wp-discourse/blob/main/admin/meta-box.php#L379>

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}' `

---

_[View the full topic](https://meta.discourse.org/t/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/90753)._
