# How to enable Discourse comments via JavaScript in Wordpress?

**URL:** https://meta.discourse.org/t/how-to-enable-discourse-comments-via-javascript-in-wordpress/74402
**Category:** WordPress
**Created:** [November 20, 2017, 6:18am UTC](https://meta.discourse.org/t/how-to-enable-discourse-comments-via-javascript-in-wordpress/74402 "2017-11-20T06:18:17Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Quintin\_Par](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/quintin_par/32/120500_2.png) [@Quintin\_Par](https://meta.discourse.org/u/Quintin_Par)
#### Post date: [November 20, 2017, 6:18am UTC](https://meta.discourse.org/t/how-to-enable-discourse-comments-via-javascript-in-wordpress/74402/1 "2017-11-20T06:18:17Z")

</div>

I am trying to use

> [@Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963/):
>
> Discourse has the ability to embed the comments from a topic in a remote site using a Javascript API that creates an IFRAME. For an example of this in action, check out [Coding Horror’s blog](http://blog.codinghorror.com/welcome-to-the-internet-of-compromised-things/#discourse-comments). The blog is run via [Ghost](https://ghost.org/) but the comments are embedded from his [Discourse forum](http://discourse.codinghorror.com/t/welcome-to-the-internet-of-compromised-things/3550). One important thing to note with this setup is that users have to navigate to your forum to post replies. This is intentional, as we feel that the posting interface on a Discourse forum is currently much richer than what we …

on my wordpress blog because WP-Discourse plugin does not currently support connecting old blog posts to existing (migrated) discourse topics.

My current plan to connect an existing blog post to discourse topic via

```
  DiscourseEmbed = { discourseUrl: 'http://discourse.example.com/',
                     topicId: 12345 };

```

However, I don’t know a way to insert HTML code at blog post level that can override existing comment code. That code seems to be outside the scope of a blog post HTML code

@tophee  
mentioned a way  
[https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963/188?u=quintin\_par](https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963/188)

Was wondering if there is a solution to add the Javascript code per each blog to set the comments?

Note:

- I am planning to set this code for each blog post manually changing the DiscourseEmbed. topicId for each post.
- For all the new posts (i.e. posts without any comments so far) I’ll be using [WP Discourse](https://github.com/discourse/wp-discourse).

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [November 20, 2017, 6:40am UTC](https://meta.discourse.org/t/how-to-enable-discourse-comments-via-javascript-in-wordpress/74402/2 "2017-11-20T06:40:48Z")

</div>

Why don’t You use the [WP Discourse](https://github.com/discourse/wp-discourse) Plugin to do that?

---

<div class="post-metadata">

### Author: ![Quintin\_Par](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/quintin_par/32/120500_2.png) [@Quintin\_Par](https://meta.discourse.org/u/Quintin_Par)
#### Post date: [November 20, 2017, 7:04am UTC](https://meta.discourse.org/t/how-to-enable-discourse-comments-via-javascript-in-wordpress/74402/3 "2017-11-20T07:04:44Z")

</div>

See

> [@How to link the existing discourse comments to wordpress posts?](https://meta.discourse.org/t/how-to-link-the-existing-discourse-comments-to-wordpress-posts/45569/3):
>
> As things are now, it is not possible to use the plugin to link existing Discourse comments to a new WordPress post. The plugin works by creating a new Discourse topic when you select ‘Publish to Discourse’ on the WordPress admin page. The linking is done by setting the WordPress post meta-data 'discourse\_permalink' to the value of the Discourse topic’s topic\_slug. It looks like it would be possible to add a feature to the plugin to ‘link to existing Discourse topic’. It would have to be suppli…

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [November 20, 2017, 7:39am UTC](https://meta.discourse.org/t/how-to-enable-discourse-comments-via-javascript-in-wordpress/74402/4 "2017-11-20T07:39:57Z")

</div>

That Post is Over a year and Half old, as far as I can see, The [WP Discourse](https://github.com/discourse/wp-discourse) Plugin has came a long way since then and comments can indeed be integrated into posts. I haven’t ever had a need to use discourse comments on wordpress but I’m sure that there is a configuration Setting available under the plugin settings for the same.

 ![Screenshot-2017-11-20 Commenting ‹ BeatParadise — WordPress](https://global.discourse-cdn.com/meta/original/3X/0/e/0ea13ef799aa877857c077c9c6e6f04c520d83f1.png)

---

<div class="post-metadata">

### Author: ![Quintin\_Par](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/quintin_par/32/120500_2.png) [@Quintin\_Par](https://meta.discourse.org/u/Quintin_Par)
#### Post date: [November 20, 2017, 7:41am UTC](https://meta.discourse.org/t/how-to-enable-discourse-comments-via-javascript-in-wordpress/74402/5 "2017-11-20T07:41:35Z")

</div>

Hmm no.

Here’s the comment from the author @simon a day back:

> [@How to link the existing discourse comments to wordpress posts?](https://meta.discourse.org/t/how-to-link-the-existing-discourse-comments-to-wordpress-posts/45569/10):
>
> Yes, it exists in my development branch of the wp-discourse-shortcodes plugin. I think it works better as a shortcode than by adding it as an option to the Publish to Discourse metabox. I’m not sure what is the best way to include this in the wp-discourse plugin. The shortcode could either be added to wp-discourse, or kept in the shortcodes plugin. In either case, I’ll get it ready to go soon.

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [November 20, 2017, 7:45am UTC](https://meta.discourse.org/t/how-to-enable-discourse-comments-via-javascript-in-wordpress/74402/6 "2017-11-20T07:45:43Z")

</div>

Are You trying to display discourse comments on existing wordpress articles?  
EDIT: Seems Like a Yes

> Did anyone pick this up, yet? Looking to link existing blog post and existing discourse topics.

You can wait until the update for plugin is out as it is going to be a lot of work anyway to individually modify all your posts over wordpress.
