# 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:** [Novembre 20, 2017, 6:18 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:** 1\
**Showing post:** 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:** [Novembre 20, 2017, 6:18 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).

---

_[View the full topic](https://meta.discourse.org/t/how-to-enable-discourse-comments-via-javascript-in-wordpress/74402)._
