# Embedding with multiple categories?

**URL:** <https://meta.discourse.org/t/embedding-with-multiple-categories/31450>\
**Category:** Feature\
**Created:** [26 Luglio 2015, 6:53pm UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450 "2015-07-26T18:53:21Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![fantapop](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fantapop/32/121823_2.png) [@fantapop](https://meta.discourse.org/u/fantapop)\
**Post date:** [18 Gennaio 2016, 3:51am UTC](https://meta.discourse.org/t/embedding-with-multiple-categories/31450/11 "2016-01-18T03:51:00Z")

</div>

We end up passing the same discourseUrl which is the instance of discourse. Then we pass either a discourseEmbedUrl or a topicId along depending on which section of the site the comments will be going in. The topic id is added to the dom during page render if it already exists.

Here is a code snippet

```
        var TOPIC_ID_ATTR = 'data-discourse-topic-id';

        var shareUrl = $('meta[property="og:url"]').attr('content'),
            topicId = $('[' + TOPIC_ID_ATTR + ']');

        var embedConfig = {
            discourseUrl: <forumUrl>
        };

        if (topicId.length > 0) {
            embedConfig.topicId = parseInt(topicId.attr(TOPIC_ID_ATTR));
        }
        else {
            embedConfig.discourseEmbedUrl = shareUrl;
        }

        window.DiscourseEmbed = embedConfig;

```

---

_[View the full topic](https://meta.discourse.org/t/embedding-with-multiple-categories/31450)._
